Zen Cart Logo
Forums / General Questions / How do I display the lowest price for a product when using Quantity Discounts?

How do I display the lowest price for a product when using Quantity Discounts?

Views: 2,089

Results 1 to 18 of 18
30 Apr 2012, 2:26 PM
#1
caffeitalia avatar

caffeitalia

New Zenner

Join Date:
Jan 2012
Location:
London / Roma
Posts:
31
Plugin Contributions:
0

How do I display the lowest price for a product when using Quantity Discounts?

Hi, I have set up several products with quantity discounts applied. But in the product listing pages the price shown is the full price. For example,

1 - 9 Cups = €2.50,
10 - 49 Cups = €2.10,
50 - 99 Cups = €2.00
100+ = €1.90

What I can't workout is how to show the lowest or 'from' price in the product listing. :frusty:
Am I missing something or a switch in the administrative side?

Forgive my poor English, This is difficult for me to word and explain, grazie

30 Apr 2012, 3:39 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How do I display the lowest price for a product when using Quantity Discounts?

You can customize the module:
/includes/modules/product_listing.php

using your templates and overrides:
/includes/modules/your_template_dir/product_listing.php

with the code:

        case 'PRODUCT_LIST_PRICE':

// bof: display lowest quantity price
//        $lc_price = zen_get_products_display_price($listing->fields['products_id']) . '<br />';
$lowest_price = zen_get_products_discount_price_qty((int)$listing->fields['products_id'],20000);
$lowest_price_tax_class = zen_products_lookup((int)$listing->fields['products_id'], 'products_tax_class_id');
$lc_price = $currencies->display_price($lowest_price, zen_get_tax_rate($lowest_price_tax_class));
// eof: display lowest quantity price

        $lc_align = 'right';
        $lc_text =  $lc_price;
2 May 2012, 3:00 PM
#3
caffeitalia avatar

caffeitalia

New Zenner

Join Date:
Jan 2012
Location:
London / Roma
Posts:
31
Plugin Contributions:
0

Re: How do I display the lowest price for a product when using Quantity Discounts?

Hi, thank you very much. :smile:

8 May 2012, 8:59 AM
#4
caffeitalia avatar

caffeitalia

New Zenner

Join Date:
Jan 2012
Location:
London / Roma
Posts:
31
Plugin Contributions:
0

Re: How do I display the lowest price for a product when using Quantity Discounts?

Hi, sorry to trouble you once again. I have noticed when I use your code to display the lowest €00.00 on the products listing page when I have my store set up as ' log on to access price ' it echos the price and not ' price unavailable '. Sorry. This is my error in not explaining how my store is set up, how can I show the lowest 'from' price in the product listing only when the customer is logged on?

8 May 2012, 1:35 PM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How do I display the lowest price for a product when using Quantity Discounts?

Have you an URL to your shop where we could perhaps peek at this? :unsure:

8 May 2012, 2:34 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How do I display the lowest price for a product when using Quantity Discounts?

Try this code:

        case 'PRODUCT_LIST_PRICE':
        $lc_price = zen_get_products_display_price($listing->fields['products_id']) . '<br />';
// bof: display lowest quantity price
if ($lc_price == TEXT_LOGIN_FOR_PRICE_PRICE . '<br />' || $lc_price == TEXT_AUTHORIZATION_PENDING_PRICE . '<br />') {
  $change_price = false;
} else {
  $change_price = true;
}

if ($change_price) {
  $lowest_price = zen_get_products_discount_price_qty((int)$listing->fields['products_id'],20000);
  $lowest_price_tax_class = zen_products_lookup((int)$listing->fields['products_id'], 'products_tax_class_id');
  $lc_price = $currencies->display_price($lowest_price, zen_get_tax_rate($lowest_price_tax_class));
}
// eof: display lowest quantity price

        $lc_align = 'right';
        $lc_text =  $lc_price;

        // more info in place of buy now
9 May 2012, 12:05 PM
#7
caffeitalia avatar

caffeitalia

New Zenner

Join Date:
Jan 2012
Location:
London / Roma
Posts:
31
Plugin Contributions:
0

Re: How do I display the lowest price for a product when using Quantity Discounts?

fantastico :cool:

17 May 2012, 12:02 PM
#8
caffeitalia avatar

caffeitalia

New Zenner

Join Date:
Jan 2012
Location:
London / Roma
Posts:
31
Plugin Contributions:
0

Re: How do I display the lowest price for a product when using Quantity Discounts?

Very sorry for once more contacting you. I have 2 problems. I am trying to modify your script to show 'a partire dal' before the price where quantity discounts are used and not show 'a partire dal' where no quantity discounts are used. But I just break it. I also have a €00.00 price showing for products are 'Call for Price'.

Can you help once more please? Very hard for newcomers but I am enjoying the learning.

17 May 2012, 2:19 PM
#9
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How do I display the lowest price for a product when using Quantity Discounts?

You could customize the code in your templates and overrides for:
tpl_product_info_display.php

on the line around 71:

  echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . zen_get_products_display_price((int)$_GET['products_id']);

to add the code in RED:

  echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . ($products_discount_type ? ' Discounts from: ' : '') . zen_get_products_display_price((int)$_GET['products_id']);

and adjust as needed ...

18 May 2012, 11:47 AM
#10
caffeitalia avatar

caffeitalia

New Zenner

Join Date:
Jan 2012
Location:
London / Roma
Posts:
31
Plugin Contributions:
0

Re: How do I display the lowest price for a product when using Quantity Discounts?

Ajeh:

You could customize the code in your templates and overrides for:
tpl_product_info_display.php

on the line around 71:

echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . zen_get_products_display_price((int)$_GET['products_id']);

> 
> to add the code in RED:
> ```
  echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . ($products_discount_type ? ' Discounts from: ' : '') . zen_get_products_display_price((int)$_GET['products_id']);

and adjust as needed ...

Hi, no still lost. I have tried to show the lowest 'discounted_price' price in the place of the base price IF quantityDiscounts are given to that product, ELSE show the baseprice. Not yet knowledgeable of zen cart :frusty: Cannot understand how to do it. Sorry.

18 May 2012, 1:54 PM
#11
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How do I display the lowest price for a product when using Quantity Discounts?

Have you an URL to where the Product with discounts is not showing the right price?

21 May 2012, 2:47 PM
#12
caffeitalia avatar

caffeitalia

New Zenner

Join Date:
Jan 2012
Location:
London / Roma
Posts:
31
Plugin Contributions:
0

Re: How do I display the lowest price for a product when using Quantity Discounts?

Sorry. I am not yet live, I am only on my laptop until I learn Zen Cart. I am finding it hard to express my attempts to modify pages.

I have on the Listing Page image in color Red what I am attempting to do and on the Product Information page.
Attachment 10508


In the Listing Page I have a price showing for 'Call for Price' products. Also to add the red text before.
Attachment 10509

In the Product Information Page I have tried to add and IF condition to show 'FROM' text and the lowest quantityDiscounted price where a product has quantity discount. ELSE to not show the text 'FROM' and only show the base price. I fail.

LOL, appology, I do not know how to explain more.

21 May 2012, 3:11 PM
#13
caffeitalia avatar

caffeitalia

New Zenner

Join Date:
Jan 2012
Location:
London / Roma
Posts:
31
Plugin Contributions:
0

Re: How do I display the lowest price for a product when using Quantity Discounts?

Maybe too much and confusion. Might best be on the Product Information Page to have an IF condition to 'HIDE' base price if the Quantity Discount table exists, just showing the QtyTable, ELSE show base Price..?

Attachment 10510

21 May 2012, 3:36 PM
#14
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: How do I display the lowest price for a product when using Quantity Discounts?

You can try for the tpl_product_info_display.php to use:

//  echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . zen_get_products_display_price((int)$_GET['products_id']);
$discount_price = zen_get_products_discount_price_qty((int)$_GET['products_id'], 5000);
$discount_price = $currencies->display_price($discount_price, $products_tax_class_id);
  echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . ($products_discount_type ? ' Discounts from: ' . $discount_price : '' . zen_get_products_display_price((int)$_GET['products_id']));
22 May 2012, 3:14 PM
#15
caffeitalia avatar

caffeitalia

New Zenner

Join Date:
Jan 2012
Location:
London / Roma
Posts:
31
Plugin Contributions:
0

Re: How do I display the lowest price for a product when using Quantity Discounts?

Ajeh:

You can try for the tpl_product_info_display.php to use:

// echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . zen_get_products_display_price((int)$_GET['products_id']);
$discount_price = zen_get_products_discount_price_qty((int)$_GET['products_id'], 5000);
$discount_price = $currencies->display_price($discount_price, $products_tax_class_id);
echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . ($products_discount_type ? ' Discounts from: ' . $discount_price : '' . zen_get_products_display_price((int)$_GET['products_id']));


Thank you so very much! Exactly what I tried to do. Please forgive for one last question. Can you point me in the direction of breaking this down and learning how to script for Zen Cart? Is there a Zen Cart writing guide?
22 May 2012, 3:21 PM
#16
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: How do I display the lowest price for a product when using Quantity Discounts?

Scripting for Zen Cart is fundamentally no different than any other PHP coding. You first need to learn PHP well, depending on how much customizing you want to do. Then you can look at existing ZC files that handle similar kinds of things to what you want to do, for examples of ZC-specific functions, variables, etc. The wiki has numerous articles about the code structure and how to handle various parts of it.

23 May 2012, 10:50 AM
#17
caffeitalia avatar

caffeitalia

New Zenner

Join Date:
Jan 2012
Location:
London / Roma
Posts:
31
Plugin Contributions:
0

Re: How do I display the lowest price for a product when using Quantity Discounts?

Yes. I have a long way to learn. I am trying to script ELSEIF command per but loosing each time.

I have in order to hide a price when quantityDiscounts are used but show a price when not quantityDiscounts used is modified the

  echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . ($products_discount_type ? ' Discounts from: ' . $discount_price : '' . zen_get_products_display_price((int)$_GET['products_id']));

to

  echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . ($products_discount_type ? ' Discounts from: '  : '' . zen_get_products_display_price((int)$_GET['products_id']));

It feels bad, but it works as intended. Yes?

Grazie

19 Feb 2013, 11:45 AM
#18
ray_the_otter avatar

ray_the_otter

Zen Follower

Join Date:
Jul 2010
Posts:
278
Plugin Contributions:
0

Re: How do I display the lowest price for a product when using Quantity Discounts?

Hi, I have applied this mod and it fits the bill nicely, however I have also added this mod to the site
Include and Exclude Tax in Prices (Net/Gross). I have struggled to get both to work together. Can anyone in this thread help me?

The full topic is @
http://www.zen-cart.com/showthread.php?76880-Display-price-with-VAT-TAX-and-Ex-VAT-TAX/page33

Any help anyone can give I will be hugely grateful, thank you.