summaryrefslogtreecommitdiff
path: root/angebote/inc/template.php
blob: fd92906f96bc1484d9d5c0925743b2928894537e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php

if ( ! defined( 'ABSPATH' ) ) {
        exit; // Exit if accessed directly.
}

function render_offer_template( $atts ) {
	global $post;
	$categories = get_the_terms( $post, 'type' );
	$spirit_type = 'Verschiedenes';

	if ( isset($categories[0]) ) {
		$spirit_type = $categories[0]->name;
	} 

	$include_post_link = false;
	if ( is_archive() || is_search() ) {
		$include_post_link = true;
	}
	if ( is_search() ) {
		$css_border_left = " card-border-left";
	} else {
		$css_border_left = "";
	}

	$offer = shortcode_atts( array(
		'spirit_type' => $spirit_type,
		'shop' => '',
		'procent' => '',
		'img_url' => '',
		'name' => '',
		'discounted_price' => '',
		'original_price' => '',
		'shipping_costs' => 'Versand ist nie kostenlos',
		'abv' => '',
		'volume' => '',
		'base_price' => '',
		'url' => '',
		'created_at' => '',
		'include_post_link' => $include_post_link,
		), $atts
	);
?>
     <div class="card <?php echo $css_border_left; ?>">
      <div class="row ">
        <div class="col-md-4">
	    <div class="card-header-dp-none">
		<p><strong>
		<span style="visibility: hidden;">
		<?php echo $offer['spirit_type']; ?><span class="float-right"><?php echo $offer['shop']; ?></span>
		</span>
		</strong></p>
	    </div>
	    <div class="card-img-overlay card-img-overlay-badge" >
	    <p class="card-text float-right rounded off-badge"  ><?php echo $offer['procent']; ?> %</p>
            </div>
	    <img src="<?php echo $offer['img_url']; ?>" class="card-img img-fluid mx-auto d-block" >
          </div>
          <div class="col-md-8 px-10">
	    <div class="card-header">
		<p><strong>
		<?php echo $offer['spirit_type']; ?><span class="float-right"><?php echo $offer['shop']; ?></span>
		</strong></p>
	    </div>
            <div class="card-block card-body px-3">
<?php
	if ( $offer['include_post_link'] ) {
?>
	    <h3 class="card-title"><a class="offer-title" href="<?php echo get_post_permalink( $post ); ?>" title="<?php echo $offer['name']; ?>"><?php echo $offer['name']; ?> <i class="material-icons icon-small" sstyle="font-size: 50%;">
launch
</i></a></h3>
<?php
	} else {
?>
	    <h3 class="card-title"><?php echo $offer['name']; ?></h3>
<?php
	}
?>
		<div class="row">
		      <p class="card-text col-md-6">
		              Preis: <?php echo $offer['discounted_price']; ?> €
			      <br>
			      Alter Preis: <?php echo $offer['original_price']; ?> €
			      <br>
			      Versand: <?php echo $offer['shipping_costs']; ?> €
		      </p>
		      <p class="card-text col-md-6">
		      	      Alkohol: <?php echo $offer['abv']; ?> %
			      <br>
			      Volumen: <?php echo $offer['volume']; ?> Liter
			      <br>
			      <?php echo $offer['base_price']; ?> € / Liter
		      </p>
                </div>
            </div>
            <div class="card-footer">
	    <a href="<?php echo $offer['url']; ?>" class="btn btn-primary">Zum Shop</a>
<?php
	if ( $offer['include_post_link'] ) {
?>
	    <a href="<?php echo get_post_permalink( $post ); ?>#title" class="btn btn-light">Detailansicht</a>
<?php
	}
?>
	    <!--p class="float-right">Preis vom <?php echo $offer['created_at']; ?></p-->
            </div>
          </div>

        </div>
      </div>
<?php
}

add_shortcode('angebot', 'render_offer_template');