Jump to content

Need help with discount and shipping (vouchers)


kant74

Recommended Posts

Hi,

 

I need to create vouchers with options "reduction on the order (amount)" and "create a new voucher with remaing amount" for some clients (PS 1.4.6.2).

 

I did a test but there is a problem. When the product is cheaper than the voucher, the remaing amount is deducted of the shipping cost (see screen capture).

 

post-286296-0-14485600-1327180589_thumb.jpg

 

I really need to change that and i would like that the reduction be only made on the total of products and not on the total order with shipping fees. I think that the calculation are in the classes/cart.php or discount.php but i don't know what i should change to make this work correctly. Is there some codes to add or to remove ?

 

Can someone help me ? It's very important.

 

Thanks.

Link to comment
Share on other sites

Hello,

 

Discounts are calculated on total order and not total products, so you are having this problem.

 

You can find responsible function for this in /classess/Cart.php at line 853

 

public function getOrderTotal($withTaxes = true, $type = Cart::BOTH)

 

At line 948 you could change

 

$order_total -= to $order_total_products -=

 

However, you need to look into it more and check if that is enough.

 

It is a quite complicated function with many different statuses and ifs, so be careful changing it. In addition, do not forget to override it in /override/classes/ to save your changes when updating.

Link to comment
Share on other sites

Thanks for your help Richard.

 

At line 948, there is :

{

$order_total -= Tools::ps_round((float)($discount->getValue(sizeof($discounts), $order_total_products, $shipping_fees, $this->id, (int)($withTaxes))), 2);

if ($discount->id_discount_type == 2)

if (in_array($discount->behavior_not_exhausted, array(1,2)))

$shrunk = true;

}

 

I changed $order_total -= Tools::ps... to $order_total_products -= Tools::ps...

but when I test, the line "total vouchers" desappear and the voucher of 5 € isn't taken any more into account.

 

It will be more difficult than i thought...

Link to comment
Share on other sites

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...