| 1 |
<?php |
| 2 |
/** |
| 3 |
* WPPIZZA_MARKUP_MAINCART Class |
| 4 |
* |
| 5 |
* @package WPPIZZA |
| 6 |
* @subpackage WPPizza Main Cart |
| 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_MAINCART |
| 19 |
* |
| 20 |
* |
| 21 |
* |
| 22 |
* ================================================================================================================================= */ |
| 23 |
|
| 24 |
class WPPIZZA_MARKUP_MAINCART{ |
| 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 |
$type = 'cart'; |
| 48 |
$markup = $this->get_markup_components($atts, $type); |
| 49 |
return $markup; |
| 50 |
} |
| 51 |
|
| 52 |
/*************************************** |
| 53 |
[markup] |
| 54 |
***************************************/ |
| 55 |
function get_markup_components($atts, $type){ |
| 56 |
static $set_cart_id = 0; $set_cart_id++; |
| 57 |
/** using cache or not **/ |
| 58 |
$using_cache = apply_filters('wppizza_filter_using_cache_plugin', false); |
| 59 |
|
| 60 |
/** get set cart style (width / height) **/ |
| 61 |
$cart_style = $this->get_cart_style($atts); |
| 62 |
|
| 63 |
/** set cart id - appending height to id to enable js to set height dynamically **/ |
| 64 |
$cart_id = ''.WPPIZZA_PREFIX.'-cart-'.$set_cart_id.'-'.$cart_style['itemised_height'].''; |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
$markup = array(); |
| 69 |
|
| 70 |
/* |
| 71 |
openingtimes - if enabled |
| 72 |
*/ |
| 73 |
$markup['openingtimes'] = WPPIZZA()->markup_openingtimes->attributes($atts, $type); |
| 74 |
|
| 75 |
|
| 76 |
/****************** |
| 77 |
cart markup - |
| 78 |
includes cart contents |
| 79 |
includes subtotals |
| 80 |
|
| 81 |
|
| 82 |
caching plugin enabled -> just create empty div |
| 83 |
with loading gif |
| 84 |
to be filled with cart by ajax request |
| 85 |
|
| 86 |
******************/ |
| 87 |
if($using_cache){ |
| 88 |
$markup['div_'] = '<div id="'.$cart_id.'" class="'.WPPIZZA_PREFIX.'-cart '.WPPIZZA_PREFIX.'-cart-nocache" ' . $cart_style['cart'] . ' >'; |
| 89 |
$markup['loading'] = '<div class="'.WPPIZZA_PREFIX.'-loading"></div>'; |
| 90 |
$markup['_div'] ='</div>'; |
| 91 |
}else{ |
| 92 |
$markup['div_'] = '<div id="'.$cart_id.'" class="'.WPPIZZA_PREFIX.'-cart" ' . $cart_style['width'] . ' >'; |
| 93 |
$markup['cart'] = WPPIZZA()->markup_maincart->cart_contents_markup_from_session(wppizza_is_orderpage(), $type, $cart_style); |
| 94 |
$markup['_div'] ='</div>'; |
| 95 |
} |
| 96 |
|
| 97 |
/* |
| 98 |
|
| 99 |
pickup checkbox |
| 100 |
|
| 101 |
*/ |
| 102 |
$markup['pickup'] = WPPIZZA() -> markup_pickup_choice -> attributes($atts, $type); |
| 103 |
|
| 104 |
/* |
| 105 |
orderinfo - if enabled |
| 106 |
*/ |
| 107 |
$markup['orderinfo'] = WPPIZZA() -> markup_orderinfo -> attributes($atts, $type); |
| 108 |
|
| 109 |
|
| 110 |
/* |
| 111 |
apply filter if required - change order of components for example - and implode for output |
| 112 |
*/ |
| 113 |
$markup = apply_filters('wppizza_filter_cart_outer_markup', $markup, $atts, $set_cart_id); |
| 114 |
$markup = trim(implode('', $markup)); |
| 115 |
return $markup; |
| 116 |
} |
| 117 |
|
| 118 |
/******************************************************* |
| 119 |
* |
| 120 |
* |
| 121 |
* create markup for cart from session values |
| 122 |
* |
| 123 |
* |
| 124 |
******************************************************/ |
| 125 |
function cart_contents_markup_from_session($is_checkout, $type = 'cart', $cart_style = array()){ |
| 126 |
|
| 127 |
$order_formatted = WPPIZZA()->order->session_formatted(); |
| 128 |
$container_class = ''.WPPIZZA_PREFIX.'-cart-info'; |
| 129 |
$button_class = ''.WPPIZZA_PREFIX.'-cart-buttons'; |
| 130 |
/* |
| 131 |
initialize empty vars, in case someone takes the |
| 132 |
conditionals out of cart.container.php |
| 133 |
(which we could do really, but it makes it clearer to figure out whats happening) |
| 134 |
*/ |
| 135 |
$is_closed = ''; |
| 136 |
$is_open = ''; |
| 137 |
$cart_empty = ''; |
| 138 |
$items = ''; |
| 139 |
$summary = ''; |
| 140 |
$pickup_note = ''; |
| 141 |
$minimum_order = ''; |
| 142 |
$checkout_button = ''; |
| 143 |
$empty_cart_button = ''; |
| 144 |
|
| 145 |
/* |
| 146 |
Modules |
| 147 |
*/ |
| 148 |
|
| 149 |
/* shop closed */ |
| 150 |
if(!wppizza_is_shop_open()){ |
| 151 |
$is_closed = WPPIZZA() -> markup_maincart -> shop_closed($order_formatted, $type); |
| 152 |
} |
| 153 |
|
| 154 |
if(wppizza_is_shop_open()){ |
| 155 |
/* |
| 156 |
convenience identifier for js alerts, although this is also checked serverside before submission |
| 157 |
*/ |
| 158 |
$is_open = '<input type="hidden" class="'.WPPIZZA_PREFIX.'-open" name="'.WPPIZZA_PREFIX.'-open" />'; |
| 159 |
/* |
| 160 |
cart empty |
| 161 |
*/ |
| 162 |
$cart_empty = WPPIZZA() -> markup_maincart -> cart_empty($order_formatted, $type); |
| 163 |
/* |
| 164 |
itemised items table |
| 165 |
*/ |
| 166 |
$items = WPPIZZA() -> markup_maincart -> itemised_markup($order_formatted, $type, $cart_style); |
| 167 |
/* |
| 168 |
subtotals/summary table |
| 169 |
*/ |
| 170 |
$summary = WPPIZZA() -> markup_maincart -> summary_markup($order_formatted, $type); |
| 171 |
/* |
| 172 |
pickup / delivery note |
| 173 |
*/ |
| 174 |
$pickup_note = WPPIZZA() -> markup_maincart -> pickup_note($order_formatted, $type); |
| 175 |
/* |
| 176 |
minimum order required text |
| 177 |
*/ |
| 178 |
$minimum_order = WPPIZZA() -> markup_maincart -> minimum_order($order_formatted, $type); |
| 179 |
/* |
| 180 |
checkout button |
| 181 |
*/ |
| 182 |
$checkout_button = WPPIZZA() -> markup_maincart -> checkout_button($order_formatted, $type); |
| 183 |
/* |
| 184 |
empty_cart button |
| 185 |
*/ |
| 186 |
$empty_cart_button = WPPIZZA() -> markup_maincart -> empty_cart_button($order_formatted, $type); |
| 187 |
} |
| 188 |
|
| 189 |
/* |
| 190 |
ini array |
| 191 |
*/ |
| 192 |
$markup = array(); |
| 193 |
/* |
| 194 |
get markup |
| 195 |
*/ |
| 196 |
if(file_exists( WPPIZZA_TEMPLATE_DIR . '/markup/cart/cart.container.php')){ |
| 197 |
require(WPPIZZA_TEMPLATE_DIR.'/markup/cart/cart.container.php'); |
| 198 |
}else{ |
| 199 |
require(WPPIZZA_PATH.'templates/markup/cart/cart.container.php'); |
| 200 |
} |
| 201 |
/* |
| 202 |
apply filter if required and implode for output |
| 203 |
*/ |
| 204 |
$markup = apply_filters('wppizza_filter_maincart_container_markup', $markup, $order_formatted, $type); |
| 205 |
|
| 206 |
/* |
| 207 |
add cart contents as json data in a hidden input we can reference globally in |
| 208 |
js if we want as wppizzaCartJson |
| 209 |
*/ |
| 210 |
$markup['jsoncart']= WPPIZZA() -> markup_maincart -> get_cart_json($order_formatted, $type); |
| 211 |
|
| 212 |
$markup = implode('', $markup); |
| 213 |
|
| 214 |
return $markup; |
| 215 |
} |
| 216 |
|
| 217 |
|
| 218 |
/* |
| 219 |
shop_closed |
| 220 |
*/ |
| 221 |
function shop_closed($order_formatted, $type){ |
| 222 |
global $wppizza_options; |
| 223 |
$txt = $wppizza_options['localization']; |
| 224 |
|
| 225 |
|
| 226 |
/* set class */ |
| 227 |
$class = WPPIZZA_PREFIX.'-closed'; |
| 228 |
|
| 229 |
/* |
| 230 |
ini array |
| 231 |
*/ |
| 232 |
$markup = array(); |
| 233 |
/* |
| 234 |
get markup |
| 235 |
*/ |
| 236 |
if(file_exists( WPPIZZA_TEMPLATE_DIR . '/markup/cart/cart.shopclosed.php')){ |
| 237 |
require(WPPIZZA_TEMPLATE_DIR.'/markup/cart/cart.shopclosed.php'); |
| 238 |
}else{ |
| 239 |
require(WPPIZZA_PATH.'templates/markup/cart/cart.shopclosed.php'); |
| 240 |
} |
| 241 |
/* |
| 242 |
apply filter if required and implode for output |
| 243 |
*/ |
| 244 |
$markup = apply_filters('wppizza_filter_maincart_shopclosed_markup', $markup); |
| 245 |
$markup = trim(implode('', $markup)); |
| 246 |
|
| 247 |
return $markup; |
| 248 |
} |
| 249 |
/* |
| 250 |
cart_empty |
| 251 |
*/ |
| 252 |
function cart_empty($order_formatted, $type){ |
| 253 |
global $wppizza_options; |
| 254 |
$txt = $wppizza_options['localization']; |
| 255 |
$items = $order_formatted['order']; |
| 256 |
|
| 257 |
/* cart isnt empty */ |
| 258 |
if(!empty($items['items'])){ |
| 259 |
return ''; |
| 260 |
} |
| 261 |
|
| 262 |
/* set class */ |
| 263 |
$class = WPPIZZA_PREFIX.'-cart-empty'; |
| 264 |
|
| 265 |
/* |
| 266 |
ini array |
| 267 |
*/ |
| 268 |
$markup = array(); |
| 269 |
/* |
| 270 |
get markup |
| 271 |
*/ |
| 272 |
if(file_exists( WPPIZZA_TEMPLATE_DIR . '/markup/cart/cart.empty.php')){ |
| 273 |
require(WPPIZZA_TEMPLATE_DIR.'/markup/cart/cart.empty.php'); |
| 274 |
}else{ |
| 275 |
require(WPPIZZA_PATH.'templates/markup/cart/cart.empty.php'); |
| 276 |
} |
| 277 |
/* |
| 278 |
apply filter if required and implode for output |
| 279 |
*/ |
| 280 |
$markup = apply_filters('wppizza_filter_maincart_cartempty_markup', $markup); |
| 281 |
$markup = trim(implode('', $markup)); |
| 282 |
|
| 283 |
return $markup; |
| 284 |
} |
| 285 |
|
| 286 |
/* |
| 287 |
pickup_note |
| 288 |
*/ |
| 289 |
function pickup_note($order_formatted, $type){ |
| 290 |
|
| 291 |
global $wppizza_options; |
| 292 |
|
| 293 |
/* |
| 294 |
skip delivery/pickup note in cart |
| 295 |
entirely if set to no_delivery, pickup only |
| 296 |
*/ |
| 297 |
if($wppizza_options['order_settings']['delivery_selected']=='no_delivery'){ |
| 298 |
$markup = ''; |
| 299 |
return $markup; |
| 300 |
} |
| 301 |
|
| 302 |
/**txt variables from settings->localization. put all text varibles into something easier to deal with*/ |
| 303 |
$txt = $wppizza_options['localization']; |
| 304 |
$is_pickup = WPPIZZA() -> session -> is_pickup(); |
| 305 |
$items = $order_formatted['order']; |
| 306 |
|
| 307 |
/* nothing in cart or not pickup */ |
| 308 |
if(empty($items['items']) || !$is_pickup ){return '';} |
| 309 |
|
| 310 |
|
| 311 |
/* set class */ |
| 312 |
$class = WPPIZZA_PREFIX.'-pickup-note'; |
| 313 |
|
| 314 |
/* |
| 315 |
ini array |
| 316 |
*/ |
| 317 |
$markup = array(); |
| 318 |
/* |
| 319 |
get markup |
| 320 |
*/ |
| 321 |
if(file_exists( WPPIZZA_TEMPLATE_DIR . '/markup/cart/cart.pickup_note.php')){ |
| 322 |
require(WPPIZZA_TEMPLATE_DIR.'/markup/cart/cart.pickup_note.php'); |
| 323 |
}else{ |
| 324 |
require(WPPIZZA_PATH.'templates/markup/cart/cart.pickup_note.php'); |
| 325 |
} |
| 326 |
/* |
| 327 |
apply filter if required and implode for output |
| 328 |
*/ |
| 329 |
$markup = apply_filters('wppizza_filter_maincart_pickup_note_markup', $markup); |
| 330 |
$markup = trim(implode('', $markup)); |
| 331 |
|
| 332 |
return $markup; |
| 333 |
} |
| 334 |
|
| 335 |
/* |
| 336 |
minimum order required text |
| 337 |
*/ |
| 338 |
function minimum_order($order_formatted, $type){ |
| 339 |
global $wppizza_options; |
| 340 |
|
| 341 |
$can_checkout = isset($order_formatted['checkout_parameters']['can_checkout']) ? $order_formatted['checkout_parameters']['can_checkout'] : false; |
| 342 |
$is_pickup = $order_formatted['checkout_parameters']['is_pickup']; |
| 343 |
$min_order_required = (float)$order_formatted['checkout_parameters']['min_order_required']; |
| 344 |
$min_order_required_free_delivery = (float)$order_formatted['checkout_parameters']['min_order_required_free_delivery']; |
| 345 |
$items = $order_formatted['order']; |
| 346 |
|
| 347 |
/* |
| 348 |
only if there are actually items in the cart and a minimum order is required |
| 349 |
display this first if the required amount is >= amount for alwasy free delivery |
| 350 |
*/ |
| 351 |
if(empty($can_checkout) && !empty($min_order_required) && !empty($items['items'])){ |
| 352 |
/* pickup selected */ |
| 353 |
if($is_pickup){ |
| 354 |
$minOrderLbl[''.$min_order_required.''] = ''.$wppizza_options['localization']['minimum_order'] . ' ' . wppizza_format_price($min_order_required) . ''; |
| 355 |
}else{ |
| 356 |
$minOrderLbl[''.$min_order_required.''] = ''.$wppizza_options['localization']['minimum_order_delivery'] . ' ' . wppizza_format_price($min_order_required) . ''; |
| 357 |
} |
| 358 |
} |
| 359 |
/* |
| 360 |
only if there are actually items in the cart and a minimum order FOR FREE DELIVERY is required and isn't pickup |
| 361 |
*/ |
| 362 |
if(empty($can_checkout) && !empty($min_order_required_free_delivery) && !empty($items['items']) && empty($is_pickup) ){ |
| 363 |
$minOrderLbl[''.$min_order_required_free_delivery.''] = ''.$wppizza_options['localization']['minimum_order_delivery'] . ' ' . wppizza_format_price($min_order_required_free_delivery) . ''; |
| 364 |
} |
| 365 |
|
| 366 |
// set priority of messages: alwasy using highest minimum amount required |
| 367 |
if(!empty($minOrderLbl)){ |
| 368 |
krsort($minOrderLbl); |
| 369 |
$minimum_order_label = reset($minOrderLbl); |
| 370 |
} |
| 371 |
// nothing to display |
| 372 |
else{ |
| 373 |
return ''; |
| 374 |
} |
| 375 |
|
| 376 |
/* set class */ |
| 377 |
$class = WPPIZZA_PREFIX.'-min-order'; |
| 378 |
|
| 379 |
/* |
| 380 |
ini array |
| 381 |
*/ |
| 382 |
$markup = array(); |
| 383 |
/* |
| 384 |
get markup |
| 385 |
*/ |
| 386 |
if(file_exists( WPPIZZA_TEMPLATE_DIR . '/markup/cart/cart.minimum_order.php')){ |
| 387 |
require(WPPIZZA_TEMPLATE_DIR.'/markup/cart/cart.minimum_order.php'); |
| 388 |
}else{ |
| 389 |
require(WPPIZZA_PATH.'templates/markup/cart/cart.minimum_order.php'); |
| 390 |
} |
| 391 |
|
| 392 |
|
| 393 |
/* |
| 394 |
apply filter if required and implode for output |
| 395 |
*/ |
| 396 |
$markup = apply_filters('wppizza_filter_maincart_minimum_order_markup', $markup); |
| 397 |
$markup = trim(implode('', $markup)); |
| 398 |
|
| 399 |
return $markup; |
| 400 |
|
| 401 |
} |
| 402 |
|
| 403 |
|
| 404 |
/* |
| 405 |
checkout button |
| 406 |
*/ |
| 407 |
function checkout_button($order_formatted, $type){ |
| 408 |
global $wppizza_options; |
| 409 |
/**txt variables from settings->localization. put all text varibles into something easier to deal with*/ |
| 410 |
$txt = $wppizza_options['localization']; |
| 411 |
$can_checkout = $order_formatted['checkout_parameters']['can_checkout']; |
| 412 |
//$is_pickup = $order_formatted['checkout_parameters']['is_pickup']; |
| 413 |
//$min_order_required = $order_formatted['checkout_parameters']['min_order_required']; |
| 414 |
$items = $order_formatted['order']; |
| 415 |
|
| 416 |
/* nothing in cart or cannot checkout (min order for example)*/ |
| 417 |
if(empty($items['items']) || empty($can_checkout) ){return '';} |
| 418 |
|
| 419 |
|
| 420 |
/* set class */ |
| 421 |
$class = WPPIZZA_PREFIX.'-checkout-button'; |
| 422 |
|
| 423 |
|
| 424 |
/* get link to order page */ |
| 425 |
$order_page_link = wppizza_page_links('orderpage'); |
| 426 |
$order_page_js_link = 'onclick="location.href=\''.$order_page_link.'\'"'; |
| 427 |
|
| 428 |
|
| 429 |
$markup = array(); |
| 430 |
|
| 431 |
/* |
| 432 |
get markup |
| 433 |
*/ |
| 434 |
if(file_exists( WPPIZZA_TEMPLATE_DIR . '/markup/cart/cart.checkout_button.php')){ |
| 435 |
require(WPPIZZA_TEMPLATE_DIR.'/markup/cart/cart.checkout_button.php'); |
| 436 |
}else{ |
| 437 |
require(WPPIZZA_PATH.'templates/markup/cart/cart.checkout_button.php'); |
| 438 |
} |
| 439 |
|
| 440 |
/* |
| 441 |
apply filter if required and implode for output |
| 442 |
*/ |
| 443 |
$markup = apply_filters('wppizza_filter_maincart_checkout_button_markup', $markup); |
| 444 |
$markup = trim(implode('', $markup)); |
| 445 |
|
| 446 |
return $markup; |
| 447 |
} |
| 448 |
|
| 449 |
/* |
| 450 |
empty_cart button |
| 451 |
*/ |
| 452 |
function empty_cart_button($order_formatted, $type){ |
| 453 |
global $wppizza_options; |
| 454 |
/**txt variables from settings->localization. put all text varibles into something easier to deal with*/ |
| 455 |
$txt = $wppizza_options['localization']; |
| 456 |
$items = $order_formatted['order']; |
| 457 |
|
| 458 |
/* nothing in cart or not enabled */ |
| 459 |
if(empty($items['items']) || empty($wppizza_options['order_settings']['empty_cart_button']) ){ |
| 460 |
return ''; |
| 461 |
} |
| 462 |
|
| 463 |
|
| 464 |
/* set class */ |
| 465 |
$class = WPPIZZA_PREFIX.'-empty-cart-button'; |
| 466 |
|
| 467 |
|
| 468 |
$markup = array(); |
| 469 |
|
| 470 |
/* |
| 471 |
get markup |
| 472 |
*/ |
| 473 |
if(file_exists( WPPIZZA_TEMPLATE_DIR . '/markup/cart/cart.empty_cart_button.php')){ |
| 474 |
require(WPPIZZA_TEMPLATE_DIR.'/markup/cart/cart.empty_cart_button.php'); |
| 475 |
}else{ |
| 476 |
require(WPPIZZA_PATH.'templates/markup/cart/cart.empty_cart_button.php'); |
| 477 |
} |
| 478 |
|
| 479 |
/* |
| 480 |
apply filter if required and implode for output |
| 481 |
*/ |
| 482 |
$markup = apply_filters('wppizza_filter_maincart_empty_cart_button_markup', $markup); |
| 483 |
$markup = trim(implode('', $markup)); |
| 484 |
|
| 485 |
return $markup; |
| 486 |
} |
| 487 |
|
| 488 |
/* |
| 489 |
|
| 490 |
|
| 491 |
subtotals |
| 492 |
|
| 493 |
$cart : either session or order_ini |
| 494 |
|
| 495 |
*/ |
| 496 |
function summary_markup($order_formatted, $type = ''){ |
| 497 |
global $wppizza_options; |
| 498 |
$items = !isset($order_formatted['order']) || !empty($order_formatted['order']['items']) ? true : false ;//if it's not set specifically , assume there are items in cart |
| 499 |
$summary_array = $order_formatted['summary']; |
| 500 |
|
| 501 |
/* |
| 502 |
remove tax total entirely if all tax rates are 0 |
| 503 |
*/ |
| 504 |
$no_tax_total = (empty($wppizza_options['order_settings']['item_tax']) && empty($wppizza_options['order_settings']['item_tax_alt']) && empty($wppizza_options['order_settings']['item_tax_alt_2']) && empty($wppizza_options['order_settings']['shipping_tax_rate'])) ? true : false; |
| 505 |
/* |
| 506 |
also remove tax total if there is only one tax (which will then be displayed instead with % applied) |
| 507 |
*/ |
| 508 |
if($no_tax_total || empty($summary_array['taxes']) || count($summary_array['taxes'])<=1){ |
| 509 |
unset($summary_array['tax_total']); |
| 510 |
} |
| 511 |
|
| 512 |
/* nothing in cart */ |
| 513 |
if(empty($items)){ |
| 514 |
return ''; |
| 515 |
} |
| 516 |
|
| 517 |
/* |
| 518 |
classes |
| 519 |
*/ |
| 520 |
/* table */ |
| 521 |
$class_table = ''.WPPIZZA_PREFIX.'-table '.WPPIZZA_PREFIX.'-order-summary'; |
| 522 |
|
| 523 |
/* tbody */ |
| 524 |
$class_tbody = WPPIZZA_PREFIX.'-table-row-group'; |
| 525 |
|
| 526 |
/* tr's */ |
| 527 |
foreach($summary_array as $sKey => $summary_values){ |
| 528 |
foreach($summary_values as $key => $values){ |
| 529 |
|
| 530 |
/** only add key if more than 2 **/ |
| 531 |
$add_key = (count($summary_values)<=1) ? '' : '_'.$key ; |
| 532 |
|
| 533 |
|
| 534 |
/** summary values to pass on to summary.php */ |
| 535 |
$summary[ $sKey . $add_key ] = $values; |
| 536 |
|
| 537 |
|
| 538 |
/* class for trs */ |
| 539 |
$class_tr[$sKey . $add_key] = ''.WPPIZZA_PREFIX.'-'.$values['class_ident'].''; |
| 540 |
|
| 541 |
/** label **/ |
| 542 |
$label[$sKey . $add_key] = !empty($values['label']) ? $values['label'] : ''; |
| 543 |
|
| 544 |
/** value **/ |
| 545 |
$value[$sKey . $add_key] = !empty($values['value_formatted']) ? $values['value_formatted'] : ''; |
| 546 |
|
| 547 |
} |
| 548 |
} |
| 549 |
|
| 550 |
|
| 551 |
$markup = array(); |
| 552 |
|
| 553 |
/* |
| 554 |
get markup |
| 555 |
*/ |
| 556 |
if(file_exists( WPPIZZA_TEMPLATE_DIR . '/markup/order/summary.php')){ |
| 557 |
require(WPPIZZA_TEMPLATE_DIR.'/markup/order/summary.php'); |
| 558 |
}else{ |
| 559 |
require(WPPIZZA_PATH.'templates/markup/order/summary.php'); |
| 560 |
} |
| 561 |
|
| 562 |
/* |
| 563 |
apply filter if required (returned $markup array will be imploded for output) |
| 564 |
*/ |
| 565 |
$markup = apply_filters('wppizza_filter_order_summary_markup', $markup, $summary, $type); |
| 566 |
|
| 567 |
/* |
| 568 |
implode for output |
| 569 |
*/ |
| 570 |
$markup = trim(implode('', $markup)); |
| 571 |
|
| 572 |
|
| 573 |
return $markup; |
| 574 |
|
| 575 |
} |
| 576 |
|
| 577 |
|
| 578 |
/************************************************************************* |
| 579 |
|
| 580 |
cart_itemised markup - values only, no inputs |
| 581 |
|
| 582 |
*************************************************************************/ |
| 583 |
function itemised_markup($order_formatted, $type = '' , $cart_style = array()){ |
| 584 |
|
| 585 |
global $wppizza_options, $blog_id; |
| 586 |
/**txt variables from settings->localization*/ |
| 587 |
$txt = $wppizza_options['localization'];/*put all text varibles into something easier to deal with**/ |
| 588 |
/* |
| 589 |
some variables simplification |
| 590 |
*/ |
| 591 |
//$order = isset($order_formatted['ordervars']) ? $order_formatted['ordervars'] : null; |
| 592 |
//$order_items = $order_formatted['order']; |
| 593 |
$items = isset($order_formatted['order']['items']) ? $order_formatted['order']['items'] : (isset($order_formatted['items']['items']) ? $order_formatted['items']['items'] : false) ;//dealing with some potential inconsistencies |
| 594 |
$no_of_items = !empty($items) ? (count($items) -1) : 0 ; /* - 1 to match $itemcount */ |
| 595 |
$multiple_taxrates = !empty($order_formatted['order']['multiple_taxrates']) ? true : ( isset($order_formatted['items']['multiple_taxrates']) ? $order_formatted['items']['multiple_taxrates'] : false);//dealing with some potential inconsistencies |
| 596 |
$blog_id = !empty($order_formatted['site']) ? $order_formatted['site']['blog_id']['value'] : $blog_id ; |
| 597 |
$order_id = isset($order_formatted['ordervars']['order_id']['value_formatted']) ? $order_formatted['ordervars']['order_id']['value_formatted'] : null; |
| 598 |
|
| 599 |
/******************** |
| 600 |
nothing in cart |
| 601 |
*********************/ |
| 602 |
if(empty($items)){ |
| 603 |
return ''; |
| 604 |
} |
| 605 |
|
| 606 |
|
| 607 |
/** |
| 608 |
class table |
| 609 |
**/ |
| 610 |
$class_table = ''.WPPIZZA_PREFIX.'-table '.WPPIZZA_PREFIX.'-order-itemised'; |
| 611 |
|
| 612 |
/** |
| 613 |
class thead |
| 614 |
**/ |
| 615 |
$class_thead = WPPIZZA_PREFIX.'-table-header-group'; |
| 616 |
|
| 617 |
/** |
| 618 |
class tbody |
| 619 |
**/ |
| 620 |
$class_tbody = WPPIZZA_PREFIX.'-table-row-group'; |
| 621 |
|
| 622 |
/** |
| 623 |
style tbody |
| 624 |
set cart height on first page load if cart not cached |
| 625 |
**/ |
| 626 |
$style_tbody = ''; |
| 627 |
if($type == 'cart' && !empty($cart_style['itemised_height'])){ |
| 628 |
$style_tbody = 'style="height:'.$cart_style['itemised_height'].'px; min-height:'.$cart_style['itemised_height'].'px"'; |
| 629 |
} |
| 630 |
|
| 631 |
/** |
| 632 |
id item row prefix |
| 633 |
as we might have cart and orderpage/orderhistory on the same |
| 634 |
page and even have the same order (i.e key) on the user purchase page |
| 635 |
multiple times, make sure it's unique |
| 636 |
**/ |
| 637 |
$id_row_prefix = ''.WPPIZZA_PREFIX.'-cart-item-'; /* cart / default */ |
| 638 |
if($type != 'cart' && $type != 'orderhistory'){ |
| 639 |
$id_row_prefix = ''.WPPIZZA_PREFIX.'-order-item-'; /* pages with order(s) on them except purchase history*/ |
| 640 |
} |
| 641 |
if($type == 'orderhistory'){ |
| 642 |
$id_row_prefix = ''.WPPIZZA_PREFIX.'-order-'.$order_id.'-item-'; /* purchase history - add order id too */ |
| 643 |
} |
| 644 |
|
| 645 |
/** |
| 646 |
class item row |
| 647 |
**/ |
| 648 |
$class_row = WPPIZZA_PREFIX.'-item-row'; |
| 649 |
$class_row_first = WPPIZZA_PREFIX.'-item-row-first'; |
| 650 |
$class_row_last = WPPIZZA_PREFIX.'-item-row-last'; |
| 651 |
$class_row_odd = WPPIZZA_PREFIX.'-item-row-odd'; |
| 652 |
$class_row_even = WPPIZZA_PREFIX.'-item-row-even'; |
| 653 |
|
| 654 |
/** |
| 655 |
class columns |
| 656 |
**/ |
| 657 |
/* classes columns : th|td - quantity*/ |
| 658 |
$class_quantity_th = WPPIZZA_PREFIX.'-item-quantity-th'; |
| 659 |
$class_quantity_td = WPPIZZA_PREFIX.'-item-quantity'; |
| 660 |
/* classes columns : th|td - article*/ |
| 661 |
$class_article_th = WPPIZZA_PREFIX.'-item-article-th'; |
| 662 |
$class_article_td = WPPIZZA_PREFIX.'-item-article'; |
| 663 |
/* classes columns : th|td - price*/ |
| 664 |
$class_price_th = WPPIZZA_PREFIX.'-item-price-th'; |
| 665 |
$class_price_td = WPPIZZA_PREFIX.'-item-price'; |
| 666 |
/* classes columns : th|td - taxrate*/ |
| 667 |
$class_taxrate_th = WPPIZZA_PREFIX.'-item-taxrate-th'; |
| 668 |
$class_taxrate_td = WPPIZZA_PREFIX.'-item-taxrate'; |
| 669 |
/* classes columns : th|td - total*/ |
| 670 |
$class_total_th = WPPIZZA_PREFIX.'-item-total-th'; |
| 671 |
$class_total_td = WPPIZZA_PREFIX.'-item-total'; |
| 672 |
|
| 673 |
/* classes columns : td - article thumbnail/title/size span*/ |
| 674 |
$class_article_thumbnail = WPPIZZA_PREFIX.'-item-thumbnail'; |
| 675 |
$class_article_no_thumbnail = WPPIZZA_PREFIX.'-item-no-thumbnail'; |
| 676 |
$class_article_title = WPPIZZA_PREFIX.'-item-title'; |
| 677 |
$class_article_size = WPPIZZA_PREFIX.'-item-size'; |
| 678 |
|
| 679 |
|
| 680 |
/* |
| 681 |
add classes |
| 682 |
*/ |
| 683 |
$item_count = 1; |
| 684 |
$row_odd_even_count = 1; |
| 685 |
foreach($items as $key => $item){ |
| 686 |
|
| 687 |
|
| 688 |
/* classes -> tr */ |
| 689 |
$items[$key]['classes']['tr'] = ''; |
| 690 |
$items[$key]['classes']['tr'] .= $class_row; |
| 691 |
$items[$key]['classes']['tr'] .= ($item_count == 1) ? ' '.$class_row_first.'' : ''; |
| 692 |
$items[$key]['classes']['tr'] .= ($item_count-1 == $no_of_items) ? ' '.$class_row_last.'' : ''; |
| 693 |
|
| 694 |
|
| 695 |
/* |
| 696 |
striped |
| 697 |
*/ |
| 698 |
//ungrouped , simply stripe the tr's |
| 699 |
if(empty($wppizza_options['layout']['items_group_sort_print_by_category'])){ |
| 700 |
$items[$key]['classes']['tr'] .= !is_int($item_count/2) ? ' '.$class_row_odd.'' : ' '.$class_row_even.''; |
| 701 |
} |
| 702 |
|
| 703 |
//grouped by category, restart count for new categories |
| 704 |
else{ |
| 705 |
/* |
| 706 |
add odd/even class |
| 707 |
*/ |
| 708 |
if(!isset($itemCatId) || $item['cat_id_selected'] != $itemCatId){ |
| 709 |
/*(re)set count */ |
| 710 |
$row_odd_even_count = 1; |
| 711 |
/* capture current cat id */ |
| 712 |
$itemCatId = $item['cat_id_selected']; |
| 713 |
} |
| 714 |
$items[$key]['classes']['tr'] .= !is_int($row_odd_even_count/2) ? ' '.$class_row_odd.'' : ' '.$class_row_even.''; |
| 715 |
/* advance counter */ |
| 716 |
$row_odd_even_count++; |
| 717 |
} |
| 718 |
|
| 719 |
$item_count++; |
| 720 |
} |
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
/* thumbnails - if enabled - on orderpage, confirmationpage, thankyoupage */ |
| 725 |
if(!empty($wppizza_options['layout']['cart_image']) && in_array($type, array('orderpage', 'confirmationpage', 'thankyoupage'))){ |
| 726 |
|
| 727 |
/* |
| 728 |
if no item in cart has any thumbnails |
| 729 |
do not display a - pointless - empty placeholder either |
| 730 |
*/ |
| 731 |
$cart_has_thumbnails = 0; |
| 732 |
|
| 733 |
/* |
| 734 |
some globals |
| 735 |
*/ |
| 736 |
$wp_upload_directory = wp_upload_dir(); |
| 737 |
/* |
| 738 |
set max image width/height (filterable) |
| 739 |
Note: only checked with equal max width/height set here |
| 740 |
when proportionally resizing dimensions !!) |
| 741 |
if changed, you (probably) need to override the related css too |
| 742 |
*/ |
| 743 |
$cart_thumbnail_max_width_height = apply_filters('wppizza_filter_cart_thumbnail_max_width_height', array(30, 30)); |
| 744 |
|
| 745 |
|
| 746 |
foreach($items as $key => $item){ |
| 747 |
|
| 748 |
/* |
| 749 |
thumbnail |
| 750 |
*/ |
| 751 |
$thumbnail_img = false; |
| 752 |
|
| 753 |
if(has_post_thumbnail( $item['post_id'] )){ |
| 754 |
|
| 755 |
/* get some attributes, check image exists, and show image (or empty placeholder) */ |
| 756 |
$_thumbnail_id = get_post_thumbnail_id($item['post_id']); |
| 757 |
$_thumbnail_meta = wp_get_attachment_metadata( $_thumbnail_id ); |
| 758 |
$_thumbnail_exist = is_file($wp_upload_directory['basedir'] . '/' . $_thumbnail_meta['file']) ? true : false; |
| 759 |
|
| 760 |
/* |
| 761 |
check for thumbnail and generate img element |
| 762 |
*/ |
| 763 |
if($_thumbnail_exist){ |
| 764 |
$_title_attribute = the_title_attribute(array('post'=>$item['post_id'], 'echo'=>0)); |
| 765 |
$_alt_attribute = get_post_meta($_thumbnail_id, '_wp_attachment_image_alt', true); |
| 766 |
$_dimensions['width'] = !empty($_thumbnail_meta['sizes']['thumbnail']['width']) ? $_thumbnail_meta['sizes']['thumbnail']['width'] : $_thumbnail_meta['width'] ; |
| 767 |
$_dimensions['height'] = !empty($_thumbnail_meta['sizes']['thumbnail']['height']) ? $_thumbnail_meta['sizes']['thumbnail']['height'] : $_thumbnail_meta['height'] ; |
| 768 |
$_max_dimension_key = array_search(max($_dimensions), $_dimensions); |
| 769 |
$_max_dimension = $_dimensions[$_max_dimension_key]; |
| 770 |
|
| 771 |
/* depending on which has max dimension, set or calculate width/height */ |
| 772 |
if($_max_dimension_key == 'width'){ |
| 773 |
$_set_width = $cart_thumbnail_max_width_height[0] ; |
| 774 |
$_max_divider = ($_dimensions['width'] / $_set_width); |
| 775 |
$_set_height = ceil($_dimensions['height'] / $_max_divider) ; |
| 776 |
}else{ |
| 777 |
$_set_height = $cart_thumbnail_max_width_height[1] ; |
| 778 |
$_max_divider = ($_dimensions['height'] / $_set_height); |
| 779 |
$_set_width = ceil($_dimensions['width'] / $_max_divider) ; |
| 780 |
} |
| 781 |
|
| 782 |
$thumbnail_img = get_the_post_thumbnail($item['post_id'], array($_set_width ,$_set_height), array('class' => '', 'alt' => empty($_alt_attribute) ? $_title_attribute : $_alt_attribute ,'title'=> $_title_attribute)); |
| 783 |
} |
| 784 |
} |
| 785 |
|
| 786 |
/* |
| 787 |
add thumbnail key to item array |
| 788 |
*/ |
| 789 |
$items[$key]['thumbnail'] = !empty($thumbnail_img) ? $thumbnail_img : '' ; |
| 790 |
|
| 791 |
/* |
| 792 |
count number of thumbnails |
| 793 |
a simple boolean would also suffice, but a count might come in handy one day |
| 794 |
*/ |
| 795 |
if(!empty($thumbnail_img)){ |
| 796 |
$cart_has_thumbnails++; |
| 797 |
} |
| 798 |
} |
| 799 |
} |
| 800 |
|
| 801 |
/* |
| 802 |
ini markup array |
| 803 |
*/ |
| 804 |
$markup = array(); |
| 805 |
|
| 806 |
/* |
| 807 |
get markup |
| 808 |
*/ |
| 809 |
if(file_exists( WPPIZZA_TEMPLATE_DIR . '/markup/order/itemised.php')){ |
| 810 |
require(WPPIZZA_TEMPLATE_DIR.'/markup/order/itemised.php'); |
| 811 |
}else{ |
| 812 |
require(WPPIZZA_PATH.'templates/markup/order/itemised.php'); |
| 813 |
} |
| 814 |
|
| 815 |
|
| 816 |
/* |
| 817 |
filter complete markup if required (return $markup array will be imploded for output) |
| 818 |
*/ |
| 819 |
$markup = apply_filters('wppizza_filter_order_itemised_markup', $markup, $blog_id , $order_id, $items, $txt, $colspan, $type); |
| 820 |
|
| 821 |
/* |
| 822 |
implode for output |
| 823 |
*/ |
| 824 |
$markup = implode('',$markup); |
| 825 |
|
| 826 |
|
| 827 |
return $markup; |
| 828 |
} |
| 829 |
|
| 830 |
/******************************************************* |
| 831 |
* |
| 832 |
* |
| 833 |
* [helpers] |
| 834 |
* |
| 835 |
* |
| 836 |
******************************************************/ |
| 837 |
/* |
| 838 |
add cart contents as json encoded object |
| 839 |
into hidden field we set as globally available |
| 840 |
'wppizzaCartJson' js object |
| 841 |
@param array |
| 842 |
@return str (html element) |
| 843 |
@since 3.12.3 |
| 844 |
*/ |
| 845 |
function get_cart_json($order_formatted = false, $type = false){ |
| 846 |
global $wppizza_options; |
| 847 |
static $json_cart_contents = null, $html_element = null ; |
| 848 |
|
| 849 |
/* |
| 850 |
only apply to type 'minicart', 'cart', 'orderpage' and 'confirmationpage' |
| 851 |
*/ |
| 852 |
if(!in_array($type, array('minicart', 'cart', 'orderpage', 'confirmationpage')) ){ |
| 853 |
return ''; |
| 854 |
} |
| 855 |
|
| 856 |
/* |
| 857 |
create json vars |
| 858 |
*/ |
| 859 |
if($json_cart_contents === null){ |
| 860 |
|
| 861 |
/****** |
| 862 |
get order values from session if not explicitly set |
| 863 |
******/ |
| 864 |
$order_formatted = empty($order_formatted) ? WPPIZZA()->order->session_formatted() : $order_formatted ; |
| 865 |
|
| 866 |
/****** |
| 867 |
something in cart ? |
| 868 |
******/ |
| 869 |
$hasItemsInCart = !empty($order_formatted['order']['items']) ? true : false; |
| 870 |
#if(empty($order_formatted['order']['items'])){ |
| 871 |
# return ''; |
| 872 |
#} |
| 873 |
|
| 874 |
/****** |
| 875 |
ini array to jsonfy |
| 876 |
******/ |
| 877 |
$json_cart_contents = array(); |
| 878 |
|
| 879 |
|
| 880 |
/****** |
| 881 |
currency |
| 882 |
******/ |
| 883 |
$json_cart_contents['currency'] = array( |
| 884 |
'iso' => $wppizza_options['order_settings']['currency'], |
| 885 |
'symbol' => $wppizza_options['order_settings']['currency_symbol'], |
| 886 |
'decimals' => (empty($wppizza_options['prices_format']) ? 0 : 2), |
| 887 |
); |
| 888 |
|
| 889 |
|
| 890 |
/****** |
| 891 |
customer data |
| 892 |
confirmation page only (for now) as everywhere else |
| 893 |
the input may still change subsequently |
| 894 |
******/ |
| 895 |
if($type == 'confirmationpage'){ |
| 896 |
$json_cart_contents['customer'] = array(); |
| 897 |
foreach($order_formatted['customer'] as $key => $vals){ |
| 898 |
$json_cart_contents['customer'][$key] = array( |
| 899 |
'label' => $vals['label'], |
| 900 |
'value' => $vals['value'], |
| 901 |
); |
| 902 |
} |
| 903 |
} |
| 904 |
|
| 905 |
|
| 906 |
/****** |
| 907 |
ordervars |
| 908 |
******/ |
| 909 |
//init array |
| 910 |
$json_cart_contents['ordervars'] = array(); |
| 911 |
|
| 912 |
//ordervars |
| 913 |
$ordervars_for_json = !empty($order_formatted['ordervars']) ? $order_formatted['ordervars'] : false ; |
| 914 |
|
| 915 |
//only pass on vars we might actually need, but make them filterable |
| 916 |
$ordervars_enabled = apply_filters('wppizza_filter_cart_json' , array('wp_user_id', 'pickup_delivery', 'payment_method', 'payment_gateway' ), $ordervars_for_json); |
| 917 |
if(!empty($ordervars_for_json)){ |
| 918 |
foreach($ordervars_for_json as $key => $item){ |
| 919 |
if(in_array($key, $ordervars_enabled )){ |
| 920 |
$json_cart_contents['ordervars'][$key] = $item['value']; |
| 921 |
} |
| 922 |
}} |
| 923 |
|
| 924 |
|
| 925 |
/****** |
| 926 |
various (shop/user/checkout ) status parameters |
| 927 |
******/ |
| 928 |
//init array |
| 929 |
$json_cart_contents['status'] = array( |
| 930 |
'can_checkout' => (!empty($order_formatted['checkout_parameters']['can_checkout']) ? true : false ), |
| 931 |
'shop_open' => wppizza_is_shop_open(), |
| 932 |
'is_pickup' => wppizza_is_pickup(), |
| 933 |
); |
| 934 |
|
| 935 |
|
| 936 |
/****** |
| 937 |
summary vars |
| 938 |
******/ |
| 939 |
$json_cart_contents['summary'] = array(); |
| 940 |
|
| 941 |
$summary_for_json = !empty($order_formatted['summary']) ? $order_formatted['summary'] : false ; |
| 942 |
|
| 943 |
//also skip if there's nothing in the cart anyway |
| 944 |
if(!empty($summary_for_json) && !empty($hasItemsInCart) ){ |
| 945 |
|
| 946 |
foreach($summary_for_json as $sKey => $sArray){ |
| 947 |
|
| 948 |
$json_cart_contents['summary'][$sKey] = array(); |
| 949 |
|
| 950 |
foreach($sArray as $key => $values){ |
| 951 |
|
| 952 |
$json_cart_contents['summary'][$sKey][$values['class_ident']] = wppizza_round($values['value']);//round in case there are some precision issues |
| 953 |
|
| 954 |
} |
| 955 |
|
| 956 |
} |
| 957 |
} |
| 958 |
|
| 959 |
/****** |
| 960 |
items in cart |
| 961 |
keys: blogid->postid->size |
| 962 |
value array: |
| 963 |
- sizeid (from wppizza->sizes) , |
| 964 |
- quantity in cart, |
| 965 |
- category selected when adding this item to the cart , |
| 966 |
- baseprice, |
| 967 |
- total price (might be different) |
| 968 |
(values can be added to in the future on an as needed basis) |
| 969 |
******/ |
| 970 |
$items_for_json = !empty($order_formatted['order']['items']) ? $order_formatted['order']['items'] : false ; |
| 971 |
|
| 972 |
|
| 973 |
if(!empty($items_for_json)){ |
| 974 |
|
| 975 |
/* |
| 976 |
Backwards compatibility: |
| 977 |
only add the 'cart' to the array if there is actually something in it |
| 978 |
*/ |
| 979 |
$json_cart_contents['cart'] = array(); |
| 980 |
|
| 981 |
foreach($items_for_json as $key => $item){ |
| 982 |
$json_cart_contents['cart'][$item['blog_id']][$item['post_id']][$item['size']] = array('sizes' => $item['sizes'], 'qty' => $item['quantity'], 'cat' => $item['cat_id_selected'], 'prc' => $item['price'], 'prcttl' => $item['pricetotal'] ); |
| 983 |
} |
| 984 |
} |
| 985 |
|
| 986 |
/******* |
| 987 |
allow to filter the object |
| 988 |
(3rd party plugins for example that want to have some additional data available in the obj that's passed to the js) |
| 989 |
*******/ |
| 990 |
$json_cart_contents = apply_filters('wppizza_filter_json_cart_contents', $json_cart_contents); |
| 991 |
|
| 992 |
//json encode and make sure to convert all quotes(") and Apostrophies (') and escape html tags/amps or the JSON.parse throws potentially all sorts of nasty errors |
| 993 |
$json_cart_contents = json_encode($json_cart_contents, JSON_FORCE_OBJECT | JSON_HEX_QUOT | JSON_HEX_APOS | JSON_HEX_AMP) ; |
| 994 |
|
| 995 |
/******* |
| 996 |
create the hidden input element we will be adding to the page |
| 997 |
any js can reference as wppizzaCartJson |
| 998 |
*******/ |
| 999 |
$html_element = "<input id='".WPPIZZA_SLUG."-cart-json' type='hidden' value='".$json_cart_contents."' />"; |
| 1000 |
|
| 1001 |
|
| 1002 |
} |
| 1003 |
|
| 1004 |
return $html_element; |
| 1005 |
} |
| 1006 |
|
| 1007 |
/****************************************************** |
| 1008 |
* set width height of *itemised* cart as set by user/shortcode/widget |
| 1009 |
* will alse be set via ajax when reloading/adding to etc cart |
| 1010 |
******************************************************/ |
| 1011 |
function get_cart_style($atts = false){ |
| 1012 |
|
| 1013 |
/* atts set width */ |
| 1014 |
if(isset($atts['width']) && $atts['width']!=''){ |
| 1015 |
$cart['width']='width:'.esc_html($atts['width']).''; |
| 1016 |
} |
| 1017 |
/* atts set cart min height */ |
| 1018 |
if(isset($atts['height']) && $atts['height']!=''){ |
| 1019 |
$cart['height']='min-height:'.(int)($atts['height']).'px'; |
| 1020 |
} |
| 1021 |
|
| 1022 |
/* atts set itemised height */ |
| 1023 |
if(isset($atts['height']) && $atts['height']!=''){ |
| 1024 |
//$itemised['height']='height:'.(int)($atts['height']).'px; max-height:'.(int)($atts['height']).'px'; |
| 1025 |
$itemised['height']=(int)($atts['height']); |
| 1026 |
} |
| 1027 |
|
| 1028 |
$cart_style = array(); |
| 1029 |
$cart_style['cart'] =(isset($cart) ) ? 'style="'.implode('; ', $cart).'"' : '';/* style declaration width/min-height*/ |
| 1030 |
$cart_style['width'] =(isset($cart['width'])) ? 'style="'.$cart['width'].'"' : '';/* style declaration width only*/ |
| 1031 |
$cart_style['itemised_height'] = (isset($itemised['height'])) ? $itemised['height'] : 0;/* height integer (used in js) */ |
| 1032 |
|
| 1033 |
return $cart_style; |
| 1034 |
} |
| 1035 |
} |
| 1036 |
?> |