PluginProbe
WPPizza – A Restaurant Plugin / 3.20
WPPizza – A Restaurant Plugin v3.20
trunk 2.16.11.28 3.19 3.19.1 3.19.2 3.19.3 3.19.4 3.19.5 3.19.6 3.19.7 3.19.7.1 3.19.7.2 3.19.7.3 3.19.7.4 3.19.8 3.19.8.1 3.19.8.2 3.19.8.3 3.19.9 3.20 3.20.1
wppizza / classes / markup / orderinfo.php

orderinfo.php in WPPizza – A Restaurant Plugin 3.20, at classes/markup/orderinfo.php

218 lines 7.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WPPIZZA_MARKUP_ORDERINFO Class
4 *
5 * @package WPPIZZA
6 * @subpackage WPPizza Order Info
7 * @copyright Copyright (c) 2015, Oliver Bach
8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 * @since 3.0
10 *
11 */
12 if ( ! defined( 'ABSPATH' ) ) exit;/*Exit if accessed directly*/
13
14 /* ================================================================================================================================= *
15 *
16 *
17 *
18 * CLASS - WPPIZZA_MARKUP_ORDERINFO
19 *
20 *
21 *
22 * ================================================================================================================================= */
23
24 class WPPIZZA_MARKUP_ORDERINFO{
25
26 /******************************************************************************
27 *
28 *
29 * [construct]
30 *
31 *
32 *******************************************************************************/
33 function __construct() {
34 }
35
36 /******************************************************************************
37 *
38 *
39 * [methods]
40 *
41 *
42 *******************************************************************************/
43 /***************************************
44 [apply attributes]
45 ***************************************/
46 function attributes($atts = null){
47
48 /***********************
49 skip if not cart or shortcode
50 ***********************/
51 if($atts['type'] != 'cart' && $atts['type'] != 'orderinfo'){
52 return;
53 }
54 /* omit if cart and not set /enabled */
55 if($atts['type'] == 'cart' && empty($atts['orderinfo']) ){
56 return;
57 }
58
59
60
61 global $wppizza_options;
62 $txt = $wppizza_options['localization'];/*put all text varibles into something easier to deal with**/
63
64
65 /***********************
66 get all available discounts to display
67 ***********************/
68 $pricing = array();
69 /**
70 percentage discounts
71 **/
72 if($wppizza_options['order_settings']['discount_selected']=='percentage'){
73 sort($wppizza_options['order_settings']['discounts']['percentage']['discounts']);
74 foreach($wppizza_options['order_settings']['discounts']['percentage']['discounts'] as $key=>$value){
75 if($value['discount']>0){
76 $pricing['pricing_discounts'][] = sprintf($txt['spend_save'], wppizza_format_price($value['min_total']), wppizza_output_format_percent($value['discount'], true));
77 }
78 }
79 }
80 /**
81 value discount
82 **/
83 if($wppizza_options['order_settings']['discount_selected']=='standard'){
84 /**get all available discounts to display***/
85 sort($wppizza_options['order_settings']['discounts']['standard']['discounts']);
86 foreach($wppizza_options['order_settings']['discounts']['standard']['discounts'] as $key=>$value){
87 if($value['discount']>0){
88 $pricing['pricing_discounts'][] = sprintf($txt['spend_save'], wppizza_format_price($value['min_total']), wppizza_format_price($value['discount']));
89 }
90 }
91 }
92
93 /**
94 delivery settings - minimum total
95 **/
96 if($wppizza_options['order_settings']['delivery_selected']=='minimum_total'){
97 if($wppizza_options['order_settings']['delivery']['minimum_total']['min_total'] !== 'n/a' && $wppizza_options['order_settings']['delivery']['minimum_total']['min_total']>0){
98 /* use highest amount set here from these 2 */
99 $amountRequiredFreeDelivery = max(array((float)$wppizza_options['order_settings']['delivery']['minimum_total']['min_total'], (float)$wppizza_options['order_settings']['order_min_for_delivery'] ));
100 $pricing['pricing_delivery'] = sprintf('%1s <span>%2s</span>', $txt['free_delivery_for_orders_of'], wppizza_format_price($amountRequiredFreeDelivery));
101 }else{
102 /* no free delivery at all - if distinctly set to n/a */
103 if($wppizza_options['order_settings']['delivery']['minimum_total']['min_total'] === 'n/a'){
104 }else{
105 $pricing['pricing_delivery'] = "".$txt['free_delivery']."";
106 }
107 }
108 }
109 /**
110 delivery settings - per item
111 **/
112 if($wppizza_options['order_settings']['delivery_selected']=='per_item'){
113 if($wppizza_options['order_settings']['delivery']['per_item']['delivery_per_item_free']>0){
114 $pricing['pricing_delivery'] = sprintf('%1s <span>%2s</span>', $txt['delivery_charges_per_item'], wppizza_format_price($wppizza_options['order_settings']['delivery']['per_item']['delivery_charge_per_item']));
115 $pricing['pricing_delivery_per_item_free'] = sprintf('%1s <span>%2s</span>', $txt['free_delivery_for_orders_of'], wppizza_format_price($wppizza_options['order_settings']['delivery']['per_item']['delivery_per_item_free']));
116 }else{
117 $pricing['pricing_delivery'] = sprintf('%1s <span>%2s</span>', $txt['delivery_charges_per_item'], wppizza_format_price($wppizza_options['order_settings']['delivery']['per_item']['delivery_charge_per_item']));
118 }
119 }
120
121
122 /***********************
123 get markup
124 ***********************/
125 $markup = $this->get_markup($atts, $txt, $pricing);
126 return $markup;
127
128 }
129
130 /***************************************
131 [markup]
132 ***************************************/
133 function get_markup($atts, $txt, $pricing){
134 static $static=0;$static++;
135
136 /*********************
137 set unique id
138 *********************/
139 $id = WPPIZZA_PREFIX.'-orders-info-'.$static;
140
141 /*********************
142 set classes
143 *********************/
144 $class= array();
145 $class[] = WPPIZZA_PREFIX.'-orders-info';
146 if(!empty($atts['class'])){
147 $class[] = esc_html($atts['class']);
148 }
149 /*
150 allow class filtering
151 implode for output
152 */
153 $class = apply_filters('wppizza_filter_orderinfo_widget_class', $class, $atts);
154 $class = trim(implode(' ', $class));
155
156 /*********************
157 set width , if defined
158 **********************/
159 $style = (!empty($atts['width'])) ? ' style="width:'.esc_html($atts['width']).'"' : '' ;
160
161
162 /* info - which parts to display */
163 $info = array();
164 /* default */
165 if(empty($atts['info'])){
166 $info['discounts'] = true;
167 $info['deliveries'] = true;
168 }
169 /* only particular info set */
170 if(!empty($atts['info'])){
171 $iExplode=explode(',',$atts['info']);
172 foreach($iExplode as $iKey){
173 $key = trim($iKey);
174 $info[$key] = true;
175 }
176 }
177
178 /** discounts **/
179 $discounts = array();
180 if(!empty($pricing['pricing_discounts']) && !empty($info['discounts'])){
181 $discounts = $pricing['pricing_discounts'];
182 }
183
184
185 /** delivery **/
186 $deliveries = array();
187 if(isset($pricing['pricing_delivery']) && !empty($info['deliveries'])){
188 $deliveries['charges'] = $pricing['pricing_delivery'];
189 if(isset($pricing['pricing_delivery_per_item_free'])){
190 $deliveries['free'] = $pricing['pricing_delivery_per_item_free'];
191 }
192 }
193
194 /*
195 ini array
196 */
197 $markup = array();
198
199 /*
200 get markup
201 */
202 if(file_exists( WPPIZZA_TEMPLATE_DIR . '/markup/global/orderinfo.php')){
203 require(WPPIZZA_TEMPLATE_DIR.'/markup/global/orderinfo.php');
204 }else{
205 require(WPPIZZA_PATH.'templates/markup/global/orderinfo.php');
206 }
207 /*
208 apply filter if required and implode for output
209 */
210 $markup = apply_filters('wppizza_filter_orderinfo_widget_markup', $markup, $atts, $static, $discounts, $deliveries);
211 $markup = trim(implode('', $markup));
212
213
214 return $markup;
215 }
216
217 }
218 ?>