Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Quantity Discount box only display percentage

Quantity Discount box only display percentage

Views: 1,054

Results 1 to 10 of 10
20 Jan 2012, 12:48 PM
#1
troll avatar

troll

New Zenner

Join Date:
Nov 2009
Posts:
42
Plugin Contributions:
0

Quantity Discount box only display percentage

Hi.

I would like to modify the Quantity Discount display box at product view.
E.g. using Quantity Discount along with product priced by attribute, makes the display somewhat irrelevant. (Calculating only the cheapest attribute)
Also, A calculated discount of a low cost item, doesn't look much...

Instead, I would like the Discount box only show the discount percentage! Not any calculated price at all!
E.g. By 10-20 pcs. and get 10% off! , By 20-40 pcs. and get 20% off! , By more then 50 pcs. and get 30% off!...
Also this would make the first column with 0% discount unnecessary to display at all...

Could this be done? :blush:

21 Jan 2012, 8:03 PM
#2
troll avatar

troll

New Zenner

Join Date:
Nov 2009
Posts:
42
Plugin Contributions:
0

Re: Quantity Discount box only display percentage

Sorry... Missed a little word, and got a misleading headline...
Anyway.. BUMP!:smile:

23 Jan 2012, 11:13 AM
#3
troll avatar

troll

New Zenner

Join Date:
Nov 2009
Posts:
42
Plugin Contributions:
0

Re: Quantity Discount box only display percentage

I'll be damned... 67 views and still no comment... :lookaroun

Well.. I have seen that this type of question has come up several times over the years, but no one I have seen either had any luck with answers...
Doesn't seem to be that impossible to achieve does it? :blink:

Maybe admin kindly would rephrase the header?... :blush:

23 Jan 2012, 2:14 PM
#4
ajeh avatar

ajeh

Oba-san

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

Re: Quantity Discount box only display percentage

That is managed by the files:
/includes/modules/products_quantity_discounts.php
/includes/templates/template_default/templates/tpl_modules_products_quantity_discounts.php

Using your templates and overrides you could customize those files to look the way you would like them to be on the display ...

24 Jan 2012, 1:33 PM
#5
troll avatar

troll

New Zenner

Join Date:
Nov 2009
Posts:
42
Plugin Contributions:
0

Re: Quantity Discount box only display percentage

Thank you Ajeh!

I've been fiddling around with them files quite a bit now, but I just don't possess the knowledge to alter that php...:no:

Got it to display the discount percent with 4 decimals in a way... -And I basically hasn't got a clue what I'm doing...:blush:

If you could find the time to help me out I would be soo grateful!
I'll even by you a ice-cream when you visit Norway!:hug:

24 Jan 2012, 2:28 PM
#6
ajeh avatar

ajeh

Oba-san

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

Re: Quantity Discount box only display percentage

Copy the file:
/includes/modules/products_quantity_discounts.php

to your templates and overrides directory:
/includes/modules/your_template_dir/products_quantity_discounts.php

and change the code around line 98 to:

    // percentage discount
    case '1':
      if ($products_discount_type_from == '0') {
//        $quantityDiscounts[$columnCount]['discounted_price'] = $display_price - ($display_price * ($products_discounts_query->fields['discount_price']/100));
        $quantityDiscounts[$columnCount]['discounted_price'] = ($products_discounts_query->fields['discount_price']/100);
      } else {
        if (!$display_specials_price) {
//          $quantityDiscounts[$columnCount]['discounted_price'] = $display_price - ($display_price * ($products_discounts_query->fields['discount_price']/100));
          $quantityDiscounts[$columnCount]['discounted_price'] = ($products_discounts_query->fields['discount_price']/100);
        } else {
//          $quantityDiscounts[$columnCount]['discounted_price'] = $display_specials_price - ($display_specials_price * ($products_discounts_query->fields['discount_price']/100));
          $quantityDiscounts[$columnCount]['discounted_price'] = ($products_discounts_query->fields['discount_price']/100);
        }
      }
    break;

then copy the file:
/includes/templates/template_default/templates/tpl_modules_products_quantity_discounts.php

to your templates and overrides directory:
/includes/templates/your_template_dir/templates/tpl_modules_products_quantity_discounts.php

and around line 55 change the code to:

<!-- <td align="center"><?php echo $quantityDiscount['show_qty'] . '<br />' . $currencies->display_price($quantityDiscount['discounted_price'], zen_get_tax_rate($products_tax_class_id)); ?></td> -->
<td align="center"><?php echo $quantityDiscount['show_qty'] . '<br />' . ($quantityDiscount['discounted_price'] * 100) . '%'; ?></td>

See if that is what you are looking to do ...

24 Jan 2012, 3:52 PM
#7
troll avatar

troll

New Zenner

Join Date:
Nov 2009
Posts:
42
Plugin Contributions:
0

Re: Quantity Discount box only display percentage

Very nice Ajeh! You are the best!:clap:

Could you please also show me how to get rid of that first td with the "base price"?
And is it possible to insert extra text in the table?

Thank you so much!:smile:

24 Jan 2012, 4:49 PM
#8
ajeh avatar

ajeh

Oba-san

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

Re: Quantity Discount box only display percentage

About line 50, change the code to:

<!--      <td align="center"><?php echo $show_qty . '<br />' . $currencies->display_price($show_price, zen_get_tax_rate($products_tax_class_id)); ?></td> -->
24 Jan 2012, 5:46 PM
#9
troll avatar

troll

New Zenner

Join Date:
Nov 2009
Posts:
42
Plugin Contributions:
0

Re: Quantity Discount box only display percentage

Thanks again Ajeh! You're my hero! :smartalec:

About the text, I did put it next to the <br/> tag, and got what I wanted. Hope that wont mess anything up!... :P

<td align="center"><?php echo $quantityDiscount['show_qty'] . ' st.<br /> -' . ($quantityDiscount['discounted_price'] * 100) . '%'; ?></td><?php

That's a double vanilla with chocolate and a strawberry on top! :D

24 Jan 2012, 5:57 PM
#10
ajeh avatar

ajeh

Oba-san

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

Re: Quantity Discount box only display percentage

Thanks for the update that this worked for you ... :smile: