-
Notifications
You must be signed in to change notification settings - Fork 2
/
wp_shopping_cart_shortcodes.php
105 lines (97 loc) · 3.78 KB
/
wp_shopping_cart_shortcodes.php
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
<?php
function wp_cart_button_handler($atts){
extract(shortcode_atts(array(
'name' => '',
'item_number' =>'',
'price' => '',
'shipping' => '0',
'var1' => '',
'var2' => '',
'var3' => '',
'thumbnail' => '',
'button_image' => '',
), $atts));
if(empty($name)){
return '<div style="color:red;">'.(__("Error! You must specify a product name in the shortcode.", "WSPSC")).'</div>';
}
if(empty($price)){
return '<div style="color:red;">'.(__("Error! You must specify a price for your product in the shortcode.", "WSPSC")).'</div>';
}
return print_wp_cart_button_for_product($name, $price, $shipping, $var1, $var2, $var3, $atts);
}
function wp_cart_display_product_handler($atts)
{
extract(shortcode_atts(array(
'name' => '',
'item_number' =>'',
'price' => '',
'shipping' => '0',
'var1' => '',
'var2' => '',
'var3' => '',
'thumbnail' => '',
'description' => '',
'button_image' => '',
), $atts));
if(empty($name)){
return '<div style="color:red;">'.(__("Error! You must specify a product name in the shortcode.", "WSPSC")).'</div>';
}
if(empty($price)){
return '<div style="color:red;">'.(__("Error! You must specify a price for your product in the shortcode.", "WSPSC")).'</div>';
}
if(empty($thumbnail)){
return '<div style="color:red;">'.(__("Error! You must specify a thumbnail image for your product in the shortcode.", "WSPSC")).'</div>';
}
$thumbnail_code = apply_filters('wspsc_product_box_thumbnail_code', '<img src="'.$thumbnail.'" />', $atts);
$currency_symbol = get_option('cart_currency_symbol');
$formatted_price = print_payment_currency($price, $currency_symbol);
$button_code = print_wp_cart_button_for_product($name, $price, $shipping, $var1, $var2, $var3, $atts);
$display_code = <<<EOT
<div class="wp_cart_product_display_box">
<div class="wp_cart_product_thumbnail">
$thumbnail_code
</div>
<div class="wp_cart_product_display_bottom">
<div class="wp_cart_product_name">
$name
</div>
<div class="wp_cart_product_description">
$description
</div>
<div class="wp_cart_product_price">
$formatted_price
</div>
<div class="wp_cart_product_button">
$button_code
</div>
</div>
</div>
EOT;
return $display_code;
}
function wspsc_compact_cart_handler($args)
{
$num_items = wpspc_get_total_cart_qty();
$curSymbol = get_option('cart_currency_symbol');
$checkout_url = get_option('cart_checkout_page_url');
$output = "";
$output .= '<div class="wpsps_compact_cart wpsps-cart-wrapper">';
$output .= '<div class="wpsps_compact_cart_container">';
if($num_items>0){
$cart_total = wpspc_get_total_cart_sub_total();
$item_message = ($num_items == 1)? "Item" : "Items";
$output .= $num_items . " " . $item_message;
$output .= '<span class="wpsps_compact_cart_price"> '. print_payment_currency($cart_total,$curSymbol).'</span>';
if(!empty($checkout_url)){
$output .= '<a class="wpsps_compact_cart_co_btn" href="'.$checkout_url.'">'.__("View Cart", "WSPSC").'</a>';
}
}
else{
$cart_total = 0;
$output .= __("Cart is empty", "WSPSC");
$output .= '<span class="wpsps_compact_cart_price"> '. print_payment_currency($cart_total,$curSymbol).'</span>';
}
$output .= '</div>';
$output .= '</div>';
return $output;
}