Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Get High and Low Price
- function my_high_low_price($product) {
- //Set Starter Prices
- $originalprice = $product['originalprice'];
- $lowprice = $product['originalprice'];
- $highprice = $product['originalprice'];
- foreach ($product['variations'] as $product_variation) {
- $variations = preg_split("[\r\n|\r|\n]", $product_variation['value']);
- foreach($variations as $val) {
- if (strpos($val,"{") === false) continue;
- $variation_modifiers = substr($val, strpos($val,"{")+1, strpos($val,"}") - (strpos($val,"{")+1));
- $arr_variation_modifiers = explode("|",$variation_modifiers);
- $pricechange = "";
- $priceset = "";
- foreach ($arr_variation_modifiers as $individual_modifier) {
- $individual_modifier = trim($individual_modifier);
- if (strtolower(substr($individual_modifier,0,2)) == "p:") {
- $priceset = substr($individual_modifier,2);
- } elseif (strtolower(substr($individual_modifier,0,1)) == "p") {
- $pricechange = substr($individual_modifier,1);
- }
- }
- if ($pricechange != "") {
- $newprice = $originalprice + $pricechange;
- } elseif ($priceset != "") {
- $newprice = $priceset;
- } else {
- $newprice = $originalprice;
- }
- if ($newprice && $newprice > $highprice) $highprice = $newprice;
- if ($newprice && $newprice < $lowprice) $lowprice = $newprice;
- }
- }
- //Show Price (and sale if applicable)
- if ($lowprice != $highprice) {
- $write = '<div class="foxyshop_price">';
- $write .= foxyshop_currency($lowprice) . " - " . foxyshop_currency($highprice);
- $write .= '</div>';
- } else {
- $write = foxyshop_price(0, 0);
- }
- return $write;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement