예제 #1
0
 /**
  * Test getSaleDiscountTypeInfo.
  */
 public function testGetSaleDiscountTypeInfo()
 {
     foreach ($this->get('productService')->getAllProducts(false, 1) as $product) {
         $productId = $product->getId();
         $info = $this->get('salemakerService')->getSaleDiscountTypeInfo($productId);
         $er = error_reporting(0);
         $type = zen_get_products_sale_discount_type($productId);
         $amount = zen_get_products_sale_discount_type($productId, false, 'amount');
         error_reporting($er);
         if (!$this->assertEquals(array('type' => $type, 'amount' => $amount), $info)) {
             echo $productId . $product->getName();
             break;
         }
     }
 }
예제 #2
0
if ($pr_attr->fields['total'] > 0) {
    if (PRODUCTS_OPTIONS_SORT_ORDER == '0') {
        $options_order_by = ' order by LPAD(popt.products_options_sort_order,11,"0")';
    } else {
        $options_order_by = ' order by popt.products_options_name';
    }
    $sql = "select distinct popt.products_options_id, popt.products_options_name, popt.products_options_sort_order,\r\n                              popt.products_options_type, popt.products_options_length, popt.products_options_comment,\r\n                              popt.products_options_size,\r\n                              popt.products_options_images_per_row,\r\n                              popt.products_options_images_style,\r\n                              popt.products_options_rows\r\n              from        " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib\r\n              where           patrib.products_id='" . (int) $_GET['products_id'] . "'\r\n              and             patrib.options_id = popt.products_options_id\r\n              and             popt.language_id = '" . (int) $_SESSION['languages_id'] . "' " . $options_order_by;
    $products_options_names = $db->Execute($sql);
    // iii 030813 added: initialize $number_of_uploads
    $number_of_uploads = 0;
    if (PRODUCTS_OPTIONS_SORT_BY_PRICE == '1') {
        $order_by = ' order by LPAD(pa.products_options_sort_order,11,"0"), pov.products_options_values_name';
    } else {
        $order_by = ' order by LPAD(pa.products_options_sort_order,11,"0"), pa.options_values_price';
    }
    $discount_type = zen_get_products_sale_discount_type((int) $_GET['products_id']);
    $discount_amount = zen_get_discount_calc((int) $_GET['products_id']);
    $zv_display_select_option = 0;
    while (!$products_options_names->EOF) {
        $products_options_array = array();
        /*
        pa.options_values_price, pa.price_prefix,
        pa.products_options_sort_order, pa.product_attribute_is_free, pa.products_attributes_weight, pa.products_attributes_weight_prefix,
        pa.attributes_default, pa.attributes_discounted, pa.attributes_image
        */
        $sql = "select    pov.products_options_values_id,\r\n                        pov.products_options_values_name,\r\n                        pa.*\r\n              from      " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov\r\n              where     pa.products_id = '" . (int) $_GET['products_id'] . "'\r\n              and       pa.options_id = '" . (int) $products_options_names->fields['products_options_id'] . "'\r\n              and       pa.options_values_id = pov.products_options_values_id\r\n              and       pov.language_id = '" . (int) $_SESSION['languages_id'] . "' " . $order_by;
        $products_options = $db->Execute($sql);
        $products_options_value_id = '';
        $products_options_details = '';
        $products_options_details_noname = '';
        $tmp_radio = '';
예제 #3
0
function zen_get_discount_calc($product_id, $attributes_id = false, $attributes_amount = false, $check_qty = false)
{
    global $discount_type_id, $sale_maker_discount;
    global $cart;
    // no charge
    if ($attributes_id > 0 and $attributes_amount == 0) {
        return 0;
    }
    $new_products_price = zen_get_products_base_price($product_id);
    $new_special_price = zen_get_products_special_price($product_id, true);
    $new_sale_price = zen_get_products_special_price($product_id, false);
    $discount_type_id = zen_get_products_sale_discount_type($product_id);
    if ($new_products_price != 0) {
        $special_price_discount = $new_special_price != 0 ? $new_special_price / $new_products_price : 1;
    } else {
        $special_price_discount = '';
    }
    $sale_maker_discount = zen_get_products_sale_discount_type($product_id, '', 'amount');
    // percentage adjustment of discount
    if ($discount_type_id == 120 or $discount_type_id == 1209 or ($discount_type_id == 110 or $discount_type_id == 1109)) {
        $sale_maker_discount = $sale_maker_discount != 0 ? (100 - $sale_maker_discount) / 100 : 1;
    }
    $qty = $check_qty;
    // fix here
    // BOF: percentage discounts apply to price
    switch (true) {
        case zen_get_discount_qty($product_id, $qty) and !$attributes_id:
            // discount quanties exist and this is not an attribute
            // $this->contents[$products_id]['qty']
            $check_discount_qty_price = zen_get_products_discount_price_qty($product_id, $qty, $attributes_amount);
            //echo 'How much 1 ' . $qty . ' : ' . $attributes_amount . ' vs ' . $check_discount_qty_price . '<br />';
            return $check_discount_qty_price;
            break;
        case zen_get_discount_qty($product_id, $qty) and zen_get_products_price_is_priced_by_attributes($product_id):
            // discount quanties exist and this is not an attribute
            // $this->contents[$products_id]['qty']
            $check_discount_qty_price = zen_get_products_discount_price_qty($product_id, $qty, $attributes_amount);
            //echo 'How much 2 ' . $qty . ' : ' . $attributes_amount . ' vs ' . $check_discount_qty_price . '<br />';
            return $check_discount_qty_price;
            break;
        case $discount_type_id == 5:
            // No Sale and No Special
            //        $sale_maker_discount = 1;
            if (!$attributes_id) {
                $sale_maker_discount = $sale_maker_discount;
            } else {
                // compute attribute amount
                if ($attributes_amount != 0) {
                    if ($special_price_discount != 0) {
                        $calc = $attributes_amount * $special_price_discount;
                    } else {
                        $calc = $attributes_amount;
                    }
                    $sale_maker_discount = $calc;
                } else {
                    $sale_maker_discount = $sale_maker_discount;
                }
            }
            //echo 'How much 3 - ' . $qty . ' : ' . $product_id . ' : ' . $qty . ' x ' .  $attributes_amount . ' vs ' . $check_discount_qty_price . ' - ' . $sale_maker_discount . '<br />';
            break;
        case $discount_type_id == 59:
            // No Sale and Special
            //        $sale_maker_discount = $special_price_discount;
            if (!$attributes_id) {
                $sale_maker_discount = $sale_maker_discount;
            } else {
                // compute attribute amount
                if ($attributes_amount != 0) {
                    $calc = $attributes_amount * $special_price_discount;
                    $sale_maker_discount = $calc;
                } else {
                    $sale_maker_discount = $sale_maker_discount;
                }
            }
            break;
            // EOF: percentage discount apply to price
            // BOF: percentage discounts apply to Sale
        // EOF: percentage discount apply to price
        // BOF: percentage discounts apply to Sale
        case $discount_type_id == 120:
            // percentage discount Sale and Special without a special
            if (!$attributes_id) {
                $sale_maker_discount = $sale_maker_discount;
            } else {
                // compute attribute amount
                if ($attributes_amount != 0) {
                    $calc = $attributes_amount * $sale_maker_discount;
                    $sale_maker_discount = $calc;
                } else {
                    $sale_maker_discount = $sale_maker_discount;
                }
            }
            break;
        case $discount_type_id == 1209:
            // percentage discount on Sale and Special with a special
            if (!$attributes_id) {
                $sale_maker_discount = $sale_maker_discount;
            } else {
                // compute attribute amount
                if ($attributes_amount != 0) {
                    $calc = $attributes_amount * $special_price_discount;
                    $calc2 = $calc - $calc * $sale_maker_discount;
                    $sale_maker_discount = $calc - $calc2;
                } else {
                    $sale_maker_discount = $sale_maker_discount;
                }
            }
            break;
            // EOF: percentage discounts apply to Sale
            // BOF: percentage discounts skip specials
        // EOF: percentage discounts apply to Sale
        // BOF: percentage discounts skip specials
        case $discount_type_id == 110:
            // percentage discount Sale and Special without a special
            if (!$attributes_id) {
                $sale_maker_discount = $sale_maker_discount;
            } else {
                // compute attribute amount
                if ($attributes_amount != 0) {
                    $calc = $attributes_amount * $sale_maker_discount;
                    $sale_maker_discount = $calc;
                } else {
                    //            $sale_maker_discount = $sale_maker_discount;
                    if ($attributes_amount != 0) {
                        //            $calc = ($attributes_amount * $special_price_discount);
                        //            $calc2 = $calc - ($calc * $sale_maker_discount);
                        //            $sale_maker_discount = $calc - $calc2;
                        $calc = $attributes_amount - $attributes_amount * $sale_maker_discount;
                        $sale_maker_discount = $calc;
                    } else {
                        $sale_maker_discount = $sale_maker_discount;
                    }
                }
            }
            break;
        case $discount_type_id == 1109:
            // percentage discount on Sale and Special with a special
            if (!$attributes_id) {
                $sale_maker_discount = $sale_maker_discount;
            } else {
                // compute attribute amount
                if ($attributes_amount != 0) {
                    $calc = $attributes_amount * $special_price_discount;
                    //            $calc2 = $calc - ($calc * $sale_maker_discount);
                    //            $sale_maker_discount = $calc - $calc2;
                    $sale_maker_discount = $calc;
                } else {
                    $sale_maker_discount = $sale_maker_discount;
                }
            }
            break;
            // EOF: percentage discounts skip specials
            // BOF: flat amount discounts
        // EOF: percentage discounts skip specials
        // BOF: flat amount discounts
        case $discount_type_id == 20:
            // flat amount discount Sale and Special without a special
            if (!$attributes_id) {
                $sale_maker_discount = $sale_maker_discount;
            } else {
                // compute attribute amount
                if ($attributes_amount != 0) {
                    $calc = $attributes_amount - $sale_maker_discount;
                    $sale_maker_discount = $calc;
                } else {
                    $sale_maker_discount = $sale_maker_discount;
                }
            }
            break;
        case $discount_type_id == 209:
            // flat amount discount on Sale and Special with a special
            if (!$attributes_id) {
                $sale_maker_discount = $sale_maker_discount;
            } else {
                // compute attribute amount
                if ($attributes_amount != 0) {
                    $calc = $attributes_amount * $special_price_discount;
                    $calc2 = $calc - $sale_maker_discount;
                    $sale_maker_discount = $calc2;
                } else {
                    $sale_maker_discount = $sale_maker_discount;
                }
            }
            break;
            // EOF: flat amount discounts
            // BOF: flat amount discounts Skip Special
        // EOF: flat amount discounts
        // BOF: flat amount discounts Skip Special
        case $discount_type_id == 10:
            // flat amount discount Sale and Special without a special
            if (!$attributes_id) {
                $sale_maker_discount = $sale_maker_discount;
            } else {
                // compute attribute amount
                if ($attributes_amount != 0) {
                    $calc = $attributes_amount - $sale_maker_discount;
                    $sale_maker_discount = $calc;
                } else {
                    $sale_maker_discount = $sale_maker_discount;
                }
            }
            break;
        case $discount_type_id == 109:
            // flat amount discount on Sale and Special with a special
            if (!$attributes_id) {
                $sale_maker_discount = 1;
            } else {
                // compute attribute amount based on Special
                if ($attributes_amount != 0) {
                    $calc = $attributes_amount * $special_price_discount;
                    $sale_maker_discount = $calc;
                } else {
                    $sale_maker_discount = $sale_maker_discount;
                }
            }
            break;
            // EOF: flat amount discounts Skip Special
            // BOF: New Price amount discounts
        // EOF: flat amount discounts Skip Special
        // BOF: New Price amount discounts
        case $discount_type_id == 220:
            // New Price amount discount Sale and Special without a special
            if (!$attributes_id) {
                $sale_maker_discount = $sale_maker_discount;
            } else {
                // compute attribute amount
                if ($attributes_amount != 0) {
                    $calc = $attributes_amount * $special_price_discount;
                    $sale_maker_discount = $calc;
                    //echo '<br />attr ' . $attributes_amount . ' spec ' . $special_price_discount . ' Calc ' . $calc . 'Calc2 ' . $calc2 . '<br />';
                } else {
                    $sale_maker_discount = $sale_maker_discount;
                }
            }
            break;
        case $discount_type_id == 2209:
            // New Price amount discount on Sale and Special with a special
            if (!$attributes_id) {
                //          $sale_maker_discount = $sale_maker_discount;
                $sale_maker_discount = $sale_maker_discount;
            } else {
                // compute attribute amount
                if ($attributes_amount != 0) {
                    $calc = $attributes_amount * $special_price_discount;
                    //echo '<br />attr ' . $attributes_amount . ' spec ' . $special_price_discount . ' Calc ' . $calc . 'Calc2 ' . $calc2 . '<br />';
                    $sale_maker_discount = $calc;
                } else {
                    $sale_maker_discount = $sale_maker_discount;
                }
            }
            break;
            // EOF: New Price amount discounts
            // BOF: New Price amount discounts - Skip Special
        // EOF: New Price amount discounts
        // BOF: New Price amount discounts - Skip Special
        case $discount_type_id == 210:
            // New Price amount discount Sale and Special without a special
            if (!$attributes_id) {
                $sale_maker_discount = $sale_maker_discount;
            } else {
                // compute attribute amount
                if ($attributes_amount != 0) {
                    $calc = $attributes_amount * $special_price_discount;
                    $sale_maker_discount = $calc;
                    //echo '<br />attr ' . $attributes_amount . ' spec ' . $special_price_discount . ' Calc ' . $calc . 'Calc2 ' . $calc2 . '<br />';
                } else {
                    $sale_maker_discount = $sale_maker_discount;
                }
            }
            break;
        case $discount_type_id == 2109:
            // New Price amount discount on Sale and Special with a special
            if (!$attributes_id) {
                //          $sale_maker_discount = $sale_maker_discount;
                $sale_maker_discount = $sale_maker_discount;
            } else {
                // compute attribute amount
                if ($attributes_amount != 0) {
                    $calc = $attributes_amount * $special_price_discount;
                    //echo '<br />attr ' . $attributes_amount . ' spec ' . $special_price_discount . ' Calc ' . $calc . 'Calc2 ' . $calc2 . '<br />';
                    $sale_maker_discount = $calc;
                } else {
                    $sale_maker_discount = $sale_maker_discount;
                }
            }
            break;
            // EOF: New Price amount discounts - Skip Special
        // EOF: New Price amount discounts - Skip Special
        case $discount_type_id == 0 or $discount_type_id == 9:
            // flat discount
            return $sale_maker_discount;
            break;
        default:
            $sale_maker_discount = 7000;
            break;
    }
    return $sale_maker_discount;
}
  <tr>
    <td colspan="2" class="breadCrumb"><?php 
echo $breadcrumb->trail(BREAD_CRUMBS_SEPARATOR);
?>
</td>
  </tr>

<tr>
<td colspan="2" class="smallText">
<?php 
if (false) {
    echo 'Looking at ' . (int) $_GET['products_id'] . '<br />';
    echo 'Base Price ' . zen_get_products_base_price((int) $_GET['products_id']) . '<br />';
    echo 'Actual Price ' . zen_get_products_actual_price((int) $_GET['products_id']) . '<br />';
    echo 'Special Price ' . zen_get_products_special_price((int) $_GET['products_id'], true) . '<br />';
    echo 'Sale Maker Discount Type ' . zen_get_products_sale_discount_type((int) $_GET['products_id']) . '<br />';
    echo 'Discount Calc ' . zen_get_discount_calc((int) $_GET['products_id']) . '<br />';
    echo 'Discount Calc Attr $100 $75 $50 $25 ' . zen_get_discount_calc((int) $_GET['products_id'], true, 100) . ' | ' . zen_get_discount_calc((int) $_GET['products_id'], true, 75) . ' | ' . zen_get_discount_calc((int) $_GET['products_id'], true, 50) . ' | ' . zen_get_discount_calc((int) $_GET['products_id'], true, 25) . '<br />';
}
?>
</td>
</tr>

<?php 
if (PRODUCT_INFO_PREVIOUS_NEXT == '1' or PRODUCT_INFO_PREVIOUS_NEXT == '3') {
    ?>
  <tr>
    <td colspan="2" align="center">
      <?php 
    require $template->get_template_dir('/tpl_products_next_previous.php', DIR_WS_TEMPLATE, $current_page_base, 'templates') . '/tpl_products_next_previous.php';
    ?>