Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This function will show your product's computed amount discounts for Quantity purchases.
- //Can be placed on the FoxyShop single product template
- function my_discount_viewer() {
- global $product;
- $discount_quantity_amount = $product['discount_quantity_amount'];
- if (!$discount_quantity_amount) return;
- $title = substr($discount_quantity_amount, 0, strpos($discount_quantity_amount,"{"));
- $str_discount = substr($discount_quantity_amount, strpos($discount_quantity_amount,"{") + 1);
- $str_discount = str_replace("}","",$str_discount);
- echo '<table class="foxyshop_discount_table">';
- echo '<thead><tr><th colspan="2">' . $title . '</th></tr></thead><tbody>';
- $arr_discount = explode("|", $str_discount);
- for ($i = 0; $i <= sizeof($arr_discount); $i++) {
- $discount = $arr_discount[$i];
- $discount_total = 0;
- if (strpos($discount,"-") === false && strpos($discount,"+") === false) continue;
- if (strpos($discount,"-") !== false) {
- $discount_operator = "-";
- $arr_inner_discount = explode("-",$discount);
- } else {
- $discount_operator = "+";
- $arr_inner_discount = explode("+",$discount);
- }
- $discount_start = $arr_inner_discount[0];
- echo "<tr><td>";
- echo $discount_start;
- if (!isset($arr_discount[$i+1])) {
- echo "+";
- } else {
- if (strpos($arr_discount[$i+1],"-") !== false) {
- $arr_second_inner_discount = explode("-",$arr_discount[$i+1]);
- } else {
- $arr_second_inner_discount = explode("+",$arr_discount[$i+1]);
- }
- $discount_end = (int)$arr_second_inner_discount[0];
- echo " - " . ($discount_end - 1);
- }
- echo "</td><td>";
- echo $discount_operator . foxyshop_currency($arr_inner_discount[1]) . '/ea.';
- echo "</td></tr>";
- }
- echo "</tbody></table>";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement