Jump to content

Question about voucher


Recommended Posts

I tried adding a voucher with a negative value and it wouldn't let me save it, so I would say that it is not possible using the Back Office. You could try modifying classes/Cart.php and change lines 628-631 from:

/* Secondly applying all vouchers to the correct amount */
foreach ($discounts AS $discount)
   if ($discount->id_discount_type != 3)
       $order_total -= floatval($discount->getValue(sizeof($discounts), $order_total_products, $shipping_fees, $this->id, intval($withTaxes)));



to:

/* Secondly applying all vouchers to the correct amount */
foreach ($discounts AS $discount)
   if ($discount->id_discount_type != 3)
   {
       if ($discount->id == 1)
           $order_total += floatval($discount->getValue(sizeof($discounts), $order_total_products, $shipping_fees, $this->id, intval($withTaxes)));
       else
           $order_total -= floatval($discount->getValue(sizeof($discounts), $order_total_products, $shipping_fees, $this->id, intval($withTaxes)));
   }




where 1 is the id of the voucher you want to be added instead of subtracted.

Link to comment
Share on other sites

Darn!!! :shut:

I am on 1.1 and it does not work for me...

this is sample of code that i made, it starts from 595 line:

                /* Secondly applying all vouchers to the correct amount */
               foreach ($discounts AS $discount)
                   if ($discount->id_discount_type != 3)
                   {
                       if ($discount->id == 1)
                           $order_total += floatval($discount->getValue(sizeof($discounts), $order_total_products, $shipping_fees, $this->id));
                       else
                           $order_total -= floatval($discount->getValue(sizeof($discounts), $order_total_products, $shipping_fees, $this->id));
           }
       }
       if ($type == 5) return $shipping_fees;
       if ($type == 6) return $wrapping_fees;
       if ($type == 3) $order_total += $shipping_fees + $wrapping_fees;
       if ($order_total < 0 AND $type != 2) return 0;
       return $order_total;
   }



As soon as i made this change front office dont work at all... HTTP 500 internal server error appears

Can you help me?

Link to comment
Share on other sites

You'll need to change lines 187-188 of shopping-cart.tpl in your theme's directory to:

{if !$priceDisplay || $priceDisplay == 2}{if $discount.id_discount == 1}{convertPrice price=$discount.value_real}{else}{convertPrice price=$discount.value_real*-1}{/if}{if $priceDisplay == 2} {l s='+Tx'}
{/if}{/if}
{if $priceDisplay}{if $discount.id_discount == 1}{convertPrice price=$discount.value_tax_exc}{else}{convertPrice price=$discount.value_tax_exc*-1}{/if}{if $priceDisplay == 2} {l s='-Tx'}{/if}{/if}



and line 82 of modules/blockcart/blockcart.tpl to:

{if $discount.id_discount != 1}-{/if}{if $priceDisplay == 1}{convertPrice price=$discount.value_tax_exc}{else}{convertPrice price=$discount.value_real}{/if}



and line 321 of modules/blockcart/ajax-cart.js to:

$('#bloc_cart_voucher_' + this.id + ' td.price').text(this.id == 1 ? abs(this.price) : this.price);

Link to comment
Share on other sites

  • 1 year later...
  • 1 year later...

I am trying to do the samebut instead of negative amount my voucher is negative %. I added a negative % voucher by editing the discount value directly on the database, and it works perfect at first. But when I confirm the order I get this error: (Fatal error (Discount -> value = -12.00)

Any ideas? thanks.

 

-------------------

 

Solved here

http://www.prestashop.com/forums/topic/160725-negative-percentage-voucher-for-fee/

Link to comment
Share on other sites

×
×
  • Create New...