Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd custom discount order in total with button
    text
    copied!<p>I have my module with my custom discount and it's OK.</p> <p>config.xml:</p> <pre><code>&lt;sales&gt; &lt;quote&gt; &lt;totals&gt; &lt;aver&gt; &lt;class&gt;Dani_Prueba_Model_Total_Aver&lt;/class&gt; &lt;after&gt;subtotal&lt;/after&gt; &lt;/aver&gt; &lt;/totals&gt; &lt;/quote&gt; &lt;/sales&gt; </code></pre> <p>My module:</p> <pre><code>&lt;?php class Dani_Prueba_Model_Total_Aver extends Mage_Sales_Model_Quote_Address_Total_Abstract{ public function collect(Mage_Sales_Model_Quote_Address $address){ $baseDiscount = 2.5; $discount = Mage::app()-&gt;getStore()-&gt;convertPrice($baseDiscount); $address-&gt;setCustomDiscount($baseDiscount); $address-&gt;setBaseGrandTotal($address-&gt;getBaseGrandTotal() - $baseDiscount); $address-&gt;setGrandTotal($address-&gt;getGrandTotal() - $discount); return $this; } public function fetch(Mage_Sales_Model_Quote_Address $address){ $this-&gt;setCode('aver'); $amount = $address-&gt;getCustomDiscount(); if ($amount != 0){ $address-&gt;addTotal(array( 'code' =&gt; $this-&gt;getCode(), 'title' =&gt; 'Custom Discount', 'value' =&gt; $amount )); } return $this; } } </code></pre> <p>This it is OK and when I add a product to cart, automatically apply my custom discount.</p> <p>But now I need do it with a button. When I add products to cart not apply discount and have the correct total. But when I click a button, apply my custom discount, and with other button "Cancel", cancel the discount. I need some similar like the function a coupon code.</p> <p>How I do it??</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload