-
Specials
I am trying to do some customization in the way specials are priced.
If ordered quantity is less than products_quantity_order_min then take the product_price
if ordered quantity is >= products_quantity_order_min then take the special price.
I made the following changes in the includes/modules/pages/shopping_cart/header_php.php
Zencart Version 1.56
$quantityField = zen_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4" class="cart_input_'.$products[$i]['id'].'"');\
if($products[$i]['quantity'] >= $products[$i]['products_quantity_order_min'])
{
$ppe = $products[$i]['final_price'];
}
else
{
$ppe=$products[$i]['products_price '];
}
$ppe = zen_round(zen_add_tax($ppe, zen_get_tax_rate($products[$i]['tax_class_id'])), $currencies->get_decimal_places($_SESSION['currency']));
$ppt = $ppe * $products[$i]['quantity'];
It does not take the products_price when if($products[$i]['quantity'] < $products[$i]['products_quantity_order_min']). Product_price is 0
Can someone help me?
-
Re: Specials
What is the value of $products[$i]['products_quantity_order_min'] at this point?
Generally speaking, the logic looks like it is good assuming you are really expecting 'products_price' to be zero and wanting to use it...
-
Re: Specials
Hi
products_quantity_order_min is the minimum qty set for this item. It is getting the correct value.
Problem I have is with the value of products_price. It is only showing 0. How do I get the products_price?
If I have set products_quantity_order_min as 10 for an item with regular Price $4 and special price $1.50.
When I add qty 5 to the cart it is taking 0.00 x 5 = 0. It should be 4 x 5 = 20.
If I add 10 Pcs then it shows 1.50 x 10 = 15
Thank you
-
Re: Specials
Had an opportunity to look over some of the code... Have questions about this product and associated special.
Starting from the end and working backwards a bit:
The special, what is its setup? Is it a base price or is it calculated off of the product's price? I.e. buy 10 of these the price is 1.50 no matter if the original price was $4 or $40. If so, pretty much can skip the rest of the questions because that's "the issue"... When identifying that the final price is a value, selection of any quantity less than the cut off point (if a base quantity of 1 or more than 0 is not entered with the "normal" price entered for that "low" quantity) results in a products_price of 0. If this is the case then it appears to be similar to an issue in github: https://github.com/zencart/zencart/issues/2807 .
The next set of questions related to is it priced by attribute? Does it have attributes? If so is the product flagged to use mixed quantities to meet the minimum order quantity? Is there otherwise a sale or a special applied to the product/its master category? Is the product by chance marked as free?
Those other questions help to track down which code path is likely applicable, but I think the first question is the issue based on a code review of how the various quantity discounts are calculated/used. Would recommend using a percentage off instead of a final price for these quantity discounts even an amount off would be better based on how the code/storage works. Seems that otherwise, to continue using a final price, not having a record for the lowest quantity available (even though there is a minimum quantity necessary), and to support purchase/display of the price for the product when less than the quantity needed for the discount have been selected there would need to be some code change to perhaps capture the lowest price if the quantity is not present instead of pushing back out 0/null/undefined.
-
2 Attachment(s)
Re: Specials
I am able to get my requirement done by setting it as special as well as quantity discounts.
1)Set the item as special by giving the special price . I want to do this to show special expiry date and also the discount %
2)By setting Quantity discounts .
Tested it. Price is calculated right
Just need two small changes in the product listing page and product info page. I have two jpegs attached to show the change I am trying to make
Attachment 18817
The code I have for in modules/product_listing is
$products_id = (int)$listing->fields['products_id'];
$getQD = ("select products_id, discount_id, discount_qty, discount_price from " . TABLE_PRODUCTS_DISCOUNT_QUANTITY . " where products_id = $products_id");
$displayQD = $db->Execute($getQD);
if($displayQD->RecordCount() > 0) {
$lc_text .= '<table style="border:1px solid #E9E9E9" cellspacing="0" cellpadding="3">';
$lc_text .= '<tr style="background: #C0C0C0; font-weight: bold"><td colspan="2"><strong>'.TEXT_PL_QD_HEADING.'</strong></td></tr>';
$lc_text .= '<tr style="background: #F5F5F5;">';
$lc_text .= '<td>' . TEXT_PL_QD_QTY . '</td>';
$lc_text .= '<td>' . TEXT_PL_QD_PRICE . '</td></tr>';
while (!$displayQD->EOF){
$lc_text .= '<tr style="background: #F5F5F5;">';
$lc_text .= '<td>' . $displayQD->fields['discount_qty'] . '</td>';
$lc_text .= '<td>' . TEXT_PL_QD_DOLLAR . number_format($displayQD->fields['discount_price'], 2, '.', '');
$lc_text .= '</td></tr>';
$displayQD->MoveNext();
}
$lc_text .= '</table>';
}
How to change the code to show
1-3 $21
4+ $10
*********************************************
Attachment 18818
From the product info page how do I remove the quantity 1 $10.
only show
1-3 $21
4+ $10
Thank you