Jump to content

Quantity discount: I need to show the unit price (after discount) instead of "save up to %.." - 1.7.5.1


BofastGlobal

Recommended Posts

Hello,

I set up a quantity discount for some of the products but the table on the frontend shows "You save up to ****". What I need is to show unit price after discount instead.

This is what i get:
01.JPG.9eeb0803c48bac3b632ab4af36c62592.JPG

Počet means PCs, Sleva means Discount, Ušetříte means You save up to.. (which i need to change to Unit price after discount)

 

 

Edited by BofastGlobal (see edit history)
Link to comment
Share on other sites

  • 1 year later...

This question is very old, but since I needed it today and couldn't find a solution I will share it here :

1- Edit \classes\product\SpecificPriceFormatter.php

After         $this->specificPrice['save'] = $priceFormatter->format((($initialPrice * $this->specificPrice['quantity']) - ($discountPrice * $this->specificPrice['quantity'])));

Add :        $this->specificPrice['unit_price'] = $priceFormatter->format($discountPrice);

 

2- Edit \themes\yourtheme\templates\catalog\_partials\product-discounts.tpl

Replace : "<td>{$quantity_discount.save}</td>" with "<td>{$quantity_discount.unit_price}</td>"

and of course edit the column name.

 

Yes, I know we should not edit class files but that's the way I could do it.
 

  • Like 1
Link to comment
Share on other sites

  • 1 month later...
On 1/7/2021 at 5:44 PM, renatototo said:

This question is very old, but since I needed it today and couldn't find a solution I will share it here :

1- Edit \classes\product\SpecificPriceFormatter.php

After         $this->specificPrice['save'] = $priceFormatter->format((($initialPrice * $this->specificPrice['quantity']) - ($discountPrice * $this->specificPrice['quantity'])));

Add :        $this->specificPrice['unit_price'] = $priceFormatter->format($discountPrice);

 

2- Edit \themes\yourtheme\templates\catalog\_partials\product-discounts.tpl

Replace : "<td>{$quantity_discount.save}</td>" with "<td>{$quantity_discount.unit_price}</td>"

and of course edit the column name.

 

Yes, I know we should not edit class files but that's the way I could do it.
 

Hello, There is no "product" folder in the "classes" directory. I'm using ps 1.7.6.7, can you help ? thank you

Link to comment
Share on other sites

  • 2 months later...

@ItriWeb Sorry for delay. Didn't received notification.

Before 1.7.7.0 you have to modify file \controllers\front\ProductController.php

After line     $row['save'] = $priceFormatter->format((($price * $row['quantity']) - ($discountPrice * $row['quantity'])));

Add             $row['unit_price'] = $priceFormatter->format($discountPrice);

And in file \themes\yourtheme\templates\catalog\_partials\product-discounts.tpl it is the same as I suggested.

 

Link to comment
Share on other sites

  • 3 months later...
En 7/1/2021 a las 5:44 PM, renatototo dijo:

This question is very old, but since I needed it today and couldn't find a solution I will share it here :

1- Edit \classes\product\SpecificPriceFormatter.php

After         $this->specificPrice['save'] = $priceFormatter->format((($initialPrice * $this->specificPrice['quantity']) - ($discountPrice * $this->specificPrice['quantity'])));

Add :        $this->specificPrice['unit_price'] = $priceFormatter->format($discountPrice);

 

2- Edit \themes\yourtheme\templates\catalog\_partials\product-discounts.tpl

Replace : "<td>{$quantity_discount.save}</td>" with "<td>{$quantity_discount.unit_price}</td>"

and of course edit the column name.

 

Yes, I know we should not edit class files but that's the way I could do it.
 

I tried on 1.7.7.3 but do not work :(

Link to comment
Share on other sites

I wrote in \classes\product\SpecificPriceFormatter.php:

        $this->specificPrice['save'] = $priceFormatter->format((($initialPrice * $this->specificPrice['quantity']) - ($discountPrice * $this->specificPrice['quantity'])));
        $this->specificPrice['unit_price'] = $priceFormatter->format($discountPrice);
        return $this->specificPrice;

 

But not work.

Edited by lunaroja (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...
On 8/27/2021 at 8:37 PM, lunaroja said:

I tried on 1.7.7.3 but do not work :(

Hello lunaroja, I did it using the 1.7.73 so it should work.

Did you also edit the tpl file as described in the point #2?

"2- Edit \themes\yourtheme\templates\catalog\_partials\product-discounts.tpl

Replace : "<td>{$quantity_discount.save}</td>" with "<td>{$quantity_discount.unit_price}</td>"

and of course edit the column name."

Link to comment
Share on other sites

Product-discounts.tpl

<section class="product-discounts">
  {if $product.quantity_discounts}
    <p class="h6 product-discounts-title">{l s='Volume discounts' d='Shop.Theme.Catalog'}</p>
    {block name='product_discount_table'}
      <table class="table-product-discounts">
        <thead>
        <tr>
          <th>{l s='Quantity' d='Shop.Theme.Catalog'}</th>
          <th>{$configuration.quantity_discount.label}</th>
          <th>{l s='You Save' d='Shop.Theme.Catalog'}</th>
          <th>{l s='Price' d='Shop.Theme.Catalog'}</th>
        </tr>
        </thead>
        <tbody>
        {foreach from=$product.quantity_discounts item='quantity_discount' name='quantity_discounts'}
          <tr data-discount-type="{$quantity_discount.reduction_type}" data-discount="{$quantity_discount.real_value}" data-discount-quantity="{$quantity_discount.quantity}">
            <td>{$quantity_discount.quantity}</td>
            <td>{$quantity_discount.discount}</td>
            <td>{$quantity_discount.save}</td>
            <td>{$quantity_discount.unit_price}</td>
          </tr>
        {/foreach}
        </tbody>
      </table>
    {/block}
  {/if}
</section>

 

SpecificPriceFormatter.php

                    $this->specificPrice['discount'] = $this->specificPrice['real_value'] . '%';
                }
            }
        }

        $this->specificPrice['save'] = $priceFormatter->format((($initialPrice * $this->specificPrice['quantity']) - ($discountPrice * $this->specificPrice['quantity'])));
        $this->specificPrice['unit_price'] = $priceFormatter->format($discountPrice);
        return $this->specificPrice;
    }

 

Link to comment
Share on other sites

hace 6 horas, lunaroja dijo:

Works better with:

$this->specificPrice['unit_price'] = $priceFormatter->format($discountPrice * $this->specificPrice['quantity']);

 

 

Works, but I prefer a % discount :)

4columna.png.8766fded935ffea36946b4122bf93a63.png

 

hace 8 horas, renatototo dijo:

Stange, I don't see anythnig wrong. Sorry

Thanks renatototo for your help :)

 

Link to comment
Share on other sites

  • 1 year later...
  • 5 months later...
On 1/7/2021 at 1:44 PM, renatototo said:

This question is very old, but since I needed it today and couldn't find a solution I will share it here :

1- Edit \classes\product\SpecificPriceFormatter.php

After         $this->specificPrice['save'] = $priceFormatter->format((($initialPrice * $this->specificPrice['quantity']) - ($discountPrice * $this->specificPrice['quantity'])));

Add :        $this->specificPrice['unit_price'] = $priceFormatter->format($discountPrice);

 

2- Edit \themes\yourtheme\templates\catalog\_partials\product-discounts.tpl

Replace : "<td>{$quantity_discount.save}</td>" with "<td>{$quantity_discount.unit_price}</td>"

and of course edit the column name.

 

Yes, I know we should not edit class files but that's the way I could do it.
 

Thank you

Link to comment
Share on other sites

  • 7 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...