Magento - Remove tax from all products quote. (Update) The Next CEO of Stack OverflowHow to create an new observer on the event catalog_product_save_beforeHolepunching of header in magento storeLearning Magento from reviewing the core filesRemove Tax & Shipping from this success.phtml code :(How to share data between Observers?Retrieve Quote Item ID after added to the cartMagento: Adding block from observer programmaticallyIs there an event that fires when the cart/quote is empty?When Adding a product to cart programatically ,the price of the product becomes zero ($0.00)Simple Observer not firing on eventRemove all products from one category programmatically
Preparing Indesign booklet with .psd graphics for print
In excess I'm lethal
Return the Closest Prime Number
Can I equip Skullclamp on a creature I am sacrificing?
Would a galaxy be visible from outside, but nearby?
Solidity! Invalid implicit conversion from string memory to bytes memory requested
What's the best way to handle refactoring a big file?
Is micro rebar a better way to reinforce concrete than rebar?
Novel about a guy who is possessed by the divine essence and the world ends?
How did people program for Consoles with multiple CPUs?
Grabbing quick drinks
MessageLevel in QGIS3
Plot of histogram similar to output from @risk
What is "(CFMCC)" on an ILS approach chart?
Inappropriate reference requests from Journal reviewers
If a black hole is created from light, can this black hole then move at speed of light?
Is it possible to search for a directory/file combination?
Can we say or write : "No, it'sn't"?
Anatomically Correct Strange Women In Ponds Distributing Swords
How to avoid supervisors with prejudiced views?
Which tube will fit a -(700 x 25c) wheel?
To not tell, not take, and not want
Multiple labels for a single equation
Why does the UK parliament need a vote on the political declaration?
Magento - Remove tax from all products quote. (Update)
The Next CEO of Stack OverflowHow to create an new observer on the event catalog_product_save_beforeHolepunching of header in magento storeLearning Magento from reviewing the core filesRemove Tax & Shipping from this success.phtml code :(How to share data between Observers?Retrieve Quote Item ID after added to the cartMagento: Adding block from observer programmaticallyIs there an event that fires when the cart/quote is empty?When Adding a product to cart programatically ,the price of the product becomes zero ($0.00)Simple Observer not firing on eventRemove all products from one category programmatically
I saw there are some post like this but I tried that answer and dit not work.
I am learning how to use magento, and What I wan to try is remove all the tax from the cliente when them have add 3 products to the cart.
I am using an observer event. And the function it run is:
Here is the config.xml
<events>
<checkout_cart_add_product_complete> <!-- identifier of the event we want to catch -->
<observers>
<checkout_cart_add_product_complete_handler> <!-- identifier of the event handler -->
<type>model</type> <!-- class method call type; valid are model, object and singleton -->
<class>descuentoiva/observer</class> <!-- observers class alias -->
<method>addCheckout</method> <!-- observer's method to be called -->
<args></args> <!-- additional arguments passed to observer -->
</checkout_cart_add_product_complete_handler>
</observers>
</checkout_cart_add_product_complete>
<events>
And this is my actual code for the fuction:
public function addCheckout(Varien_Event_Observer $observer)
$cart = Mage::getModel('checkout/cart')->getQuote();
if (count($cart->getAllItems()) >= 3)
$products = $cart->getAllVisibleItems();
foreach($products as $item)
echo $item->getPriceInclTax()."<br>";
if ($item->getTaxAmount() > 0)
$item->setTaxPercent(0);
$item->setTaxAmount(0);
$item->setBaseTaxAmount(0);
$item->save();
$cart->save();
#die("patata");
But when I look the checkout it did not work.
magento-1.9 code code-analysis
add a comment |
I saw there are some post like this but I tried that answer and dit not work.
I am learning how to use magento, and What I wan to try is remove all the tax from the cliente when them have add 3 products to the cart.
I am using an observer event. And the function it run is:
Here is the config.xml
<events>
<checkout_cart_add_product_complete> <!-- identifier of the event we want to catch -->
<observers>
<checkout_cart_add_product_complete_handler> <!-- identifier of the event handler -->
<type>model</type> <!-- class method call type; valid are model, object and singleton -->
<class>descuentoiva/observer</class> <!-- observers class alias -->
<method>addCheckout</method> <!-- observer's method to be called -->
<args></args> <!-- additional arguments passed to observer -->
</checkout_cart_add_product_complete_handler>
</observers>
</checkout_cart_add_product_complete>
<events>
And this is my actual code for the fuction:
public function addCheckout(Varien_Event_Observer $observer)
$cart = Mage::getModel('checkout/cart')->getQuote();
if (count($cart->getAllItems()) >= 3)
$products = $cart->getAllVisibleItems();
foreach($products as $item)
echo $item->getPriceInclTax()."<br>";
if ($item->getTaxAmount() > 0)
$item->setTaxPercent(0);
$item->setTaxAmount(0);
$item->setBaseTaxAmount(0);
$item->save();
$cart->save();
#die("patata");
But when I look the checkout it did not work.
magento-1.9 code code-analysis
add a comment |
I saw there are some post like this but I tried that answer and dit not work.
I am learning how to use magento, and What I wan to try is remove all the tax from the cliente when them have add 3 products to the cart.
I am using an observer event. And the function it run is:
Here is the config.xml
<events>
<checkout_cart_add_product_complete> <!-- identifier of the event we want to catch -->
<observers>
<checkout_cart_add_product_complete_handler> <!-- identifier of the event handler -->
<type>model</type> <!-- class method call type; valid are model, object and singleton -->
<class>descuentoiva/observer</class> <!-- observers class alias -->
<method>addCheckout</method> <!-- observer's method to be called -->
<args></args> <!-- additional arguments passed to observer -->
</checkout_cart_add_product_complete_handler>
</observers>
</checkout_cart_add_product_complete>
<events>
And this is my actual code for the fuction:
public function addCheckout(Varien_Event_Observer $observer)
$cart = Mage::getModel('checkout/cart')->getQuote();
if (count($cart->getAllItems()) >= 3)
$products = $cart->getAllVisibleItems();
foreach($products as $item)
echo $item->getPriceInclTax()."<br>";
if ($item->getTaxAmount() > 0)
$item->setTaxPercent(0);
$item->setTaxAmount(0);
$item->setBaseTaxAmount(0);
$item->save();
$cart->save();
#die("patata");
But when I look the checkout it did not work.
magento-1.9 code code-analysis
I saw there are some post like this but I tried that answer and dit not work.
I am learning how to use magento, and What I wan to try is remove all the tax from the cliente when them have add 3 products to the cart.
I am using an observer event. And the function it run is:
Here is the config.xml
<events>
<checkout_cart_add_product_complete> <!-- identifier of the event we want to catch -->
<observers>
<checkout_cart_add_product_complete_handler> <!-- identifier of the event handler -->
<type>model</type> <!-- class method call type; valid are model, object and singleton -->
<class>descuentoiva/observer</class> <!-- observers class alias -->
<method>addCheckout</method> <!-- observer's method to be called -->
<args></args> <!-- additional arguments passed to observer -->
</checkout_cart_add_product_complete_handler>
</observers>
</checkout_cart_add_product_complete>
<events>
And this is my actual code for the fuction:
public function addCheckout(Varien_Event_Observer $observer)
$cart = Mage::getModel('checkout/cart')->getQuote();
if (count($cart->getAllItems()) >= 3)
$products = $cart->getAllVisibleItems();
foreach($products as $item)
echo $item->getPriceInclTax()."<br>";
if ($item->getTaxAmount() > 0)
$item->setTaxPercent(0);
$item->setTaxAmount(0);
$item->setBaseTaxAmount(0);
$item->save();
$cart->save();
#die("patata");
But when I look the checkout it did not work.
magento-1.9 code code-analysis
magento-1.9 code code-analysis
edited 1 hour ago
Teja Bhagavan Kollepara
3,01241949
3,01241949
asked Jun 9 '16 at 11:21
mohamet montemohamet monte
66
66
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You also have to config your event in config.xml. Learn here
Now, we need to use this event checkout_cart_product_add_after
and checkout_cart_product_update_after
.
In your config.xml
<global>
..
..
<events>
<checkout_cart_product_add_after>
<observers>
<my_module_product_add_after>
<type>singleton</type>
<class>modulename/observer</class>
<method>checkout_cart_product_add_after</method>
</my_module_product_add_after>
</observers>
</checkout_cart_product_add_after>
</events>
..
..
</global>
Now function checkout_cart_product_add_after()
in model/observer.php
public function checkout_cart_product_add_after(Varien_Event_Observer $observer)
$quote = $observer->getEvent()->getQuote();
if (count($quote->getAllItems()) >= 3)
$items = $quote->getAllVisibleItems();
foreach($items as $item)
$item
->setTaxAmount(0)
->setBaseTaxAmount(0)
->save();
Mage::log('my log', null, 'my-log.log'); //creates log file if this function is called
This will set tax to 0 for all items that are in cart. You would want to check sales_flat_quote_item
table.
Because you would also want to check this event on item update on cart, so you have to set another event for this checkout_cart_product_update_after
.
you can call same function for this event too.
I haven't tested, but this should work.
I will try but I thinked that prove i done and dit not work. And config.xml is configured. When I use again my own computer I will update all data with config.xml and the prove. Ty Adarsh
– mohamet monte
Jun 9 '16 at 12:36
It did not work Adarsh
– mohamet monte
Jun 10 '16 at 7:09
Any error? And did it create a log fine called my-log?
– Adarsh Khatri
Jun 10 '16 at 7:28
Yes it create the log
– mohamet monte
Jun 10 '16 at 7:39
Check your var/log folder
– Adarsh Khatri
Jun 10 '16 at 7:43
|
show 4 more comments
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f120158%2fmagento-remove-tax-from-all-products-quote-update%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You also have to config your event in config.xml. Learn here
Now, we need to use this event checkout_cart_product_add_after
and checkout_cart_product_update_after
.
In your config.xml
<global>
..
..
<events>
<checkout_cart_product_add_after>
<observers>
<my_module_product_add_after>
<type>singleton</type>
<class>modulename/observer</class>
<method>checkout_cart_product_add_after</method>
</my_module_product_add_after>
</observers>
</checkout_cart_product_add_after>
</events>
..
..
</global>
Now function checkout_cart_product_add_after()
in model/observer.php
public function checkout_cart_product_add_after(Varien_Event_Observer $observer)
$quote = $observer->getEvent()->getQuote();
if (count($quote->getAllItems()) >= 3)
$items = $quote->getAllVisibleItems();
foreach($items as $item)
$item
->setTaxAmount(0)
->setBaseTaxAmount(0)
->save();
Mage::log('my log', null, 'my-log.log'); //creates log file if this function is called
This will set tax to 0 for all items that are in cart. You would want to check sales_flat_quote_item
table.
Because you would also want to check this event on item update on cart, so you have to set another event for this checkout_cart_product_update_after
.
you can call same function for this event too.
I haven't tested, but this should work.
I will try but I thinked that prove i done and dit not work. And config.xml is configured. When I use again my own computer I will update all data with config.xml and the prove. Ty Adarsh
– mohamet monte
Jun 9 '16 at 12:36
It did not work Adarsh
– mohamet monte
Jun 10 '16 at 7:09
Any error? And did it create a log fine called my-log?
– Adarsh Khatri
Jun 10 '16 at 7:28
Yes it create the log
– mohamet monte
Jun 10 '16 at 7:39
Check your var/log folder
– Adarsh Khatri
Jun 10 '16 at 7:43
|
show 4 more comments
You also have to config your event in config.xml. Learn here
Now, we need to use this event checkout_cart_product_add_after
and checkout_cart_product_update_after
.
In your config.xml
<global>
..
..
<events>
<checkout_cart_product_add_after>
<observers>
<my_module_product_add_after>
<type>singleton</type>
<class>modulename/observer</class>
<method>checkout_cart_product_add_after</method>
</my_module_product_add_after>
</observers>
</checkout_cart_product_add_after>
</events>
..
..
</global>
Now function checkout_cart_product_add_after()
in model/observer.php
public function checkout_cart_product_add_after(Varien_Event_Observer $observer)
$quote = $observer->getEvent()->getQuote();
if (count($quote->getAllItems()) >= 3)
$items = $quote->getAllVisibleItems();
foreach($items as $item)
$item
->setTaxAmount(0)
->setBaseTaxAmount(0)
->save();
Mage::log('my log', null, 'my-log.log'); //creates log file if this function is called
This will set tax to 0 for all items that are in cart. You would want to check sales_flat_quote_item
table.
Because you would also want to check this event on item update on cart, so you have to set another event for this checkout_cart_product_update_after
.
you can call same function for this event too.
I haven't tested, but this should work.
I will try but I thinked that prove i done and dit not work. And config.xml is configured. When I use again my own computer I will update all data with config.xml and the prove. Ty Adarsh
– mohamet monte
Jun 9 '16 at 12:36
It did not work Adarsh
– mohamet monte
Jun 10 '16 at 7:09
Any error? And did it create a log fine called my-log?
– Adarsh Khatri
Jun 10 '16 at 7:28
Yes it create the log
– mohamet monte
Jun 10 '16 at 7:39
Check your var/log folder
– Adarsh Khatri
Jun 10 '16 at 7:43
|
show 4 more comments
You also have to config your event in config.xml. Learn here
Now, we need to use this event checkout_cart_product_add_after
and checkout_cart_product_update_after
.
In your config.xml
<global>
..
..
<events>
<checkout_cart_product_add_after>
<observers>
<my_module_product_add_after>
<type>singleton</type>
<class>modulename/observer</class>
<method>checkout_cart_product_add_after</method>
</my_module_product_add_after>
</observers>
</checkout_cart_product_add_after>
</events>
..
..
</global>
Now function checkout_cart_product_add_after()
in model/observer.php
public function checkout_cart_product_add_after(Varien_Event_Observer $observer)
$quote = $observer->getEvent()->getQuote();
if (count($quote->getAllItems()) >= 3)
$items = $quote->getAllVisibleItems();
foreach($items as $item)
$item
->setTaxAmount(0)
->setBaseTaxAmount(0)
->save();
Mage::log('my log', null, 'my-log.log'); //creates log file if this function is called
This will set tax to 0 for all items that are in cart. You would want to check sales_flat_quote_item
table.
Because you would also want to check this event on item update on cart, so you have to set another event for this checkout_cart_product_update_after
.
you can call same function for this event too.
I haven't tested, but this should work.
You also have to config your event in config.xml. Learn here
Now, we need to use this event checkout_cart_product_add_after
and checkout_cart_product_update_after
.
In your config.xml
<global>
..
..
<events>
<checkout_cart_product_add_after>
<observers>
<my_module_product_add_after>
<type>singleton</type>
<class>modulename/observer</class>
<method>checkout_cart_product_add_after</method>
</my_module_product_add_after>
</observers>
</checkout_cart_product_add_after>
</events>
..
..
</global>
Now function checkout_cart_product_add_after()
in model/observer.php
public function checkout_cart_product_add_after(Varien_Event_Observer $observer)
$quote = $observer->getEvent()->getQuote();
if (count($quote->getAllItems()) >= 3)
$items = $quote->getAllVisibleItems();
foreach($items as $item)
$item
->setTaxAmount(0)
->setBaseTaxAmount(0)
->save();
Mage::log('my log', null, 'my-log.log'); //creates log file if this function is called
This will set tax to 0 for all items that are in cart. You would want to check sales_flat_quote_item
table.
Because you would also want to check this event on item update on cart, so you have to set another event for this checkout_cart_product_update_after
.
you can call same function for this event too.
I haven't tested, but this should work.
edited Apr 13 '17 at 12:55
Community♦
1
1
answered Jun 9 '16 at 12:10
Adarsh KhatriAdarsh Khatri
6,78511644
6,78511644
I will try but I thinked that prove i done and dit not work. And config.xml is configured. When I use again my own computer I will update all data with config.xml and the prove. Ty Adarsh
– mohamet monte
Jun 9 '16 at 12:36
It did not work Adarsh
– mohamet monte
Jun 10 '16 at 7:09
Any error? And did it create a log fine called my-log?
– Adarsh Khatri
Jun 10 '16 at 7:28
Yes it create the log
– mohamet monte
Jun 10 '16 at 7:39
Check your var/log folder
– Adarsh Khatri
Jun 10 '16 at 7:43
|
show 4 more comments
I will try but I thinked that prove i done and dit not work. And config.xml is configured. When I use again my own computer I will update all data with config.xml and the prove. Ty Adarsh
– mohamet monte
Jun 9 '16 at 12:36
It did not work Adarsh
– mohamet monte
Jun 10 '16 at 7:09
Any error? And did it create a log fine called my-log?
– Adarsh Khatri
Jun 10 '16 at 7:28
Yes it create the log
– mohamet monte
Jun 10 '16 at 7:39
Check your var/log folder
– Adarsh Khatri
Jun 10 '16 at 7:43
I will try but I thinked that prove i done and dit not work. And config.xml is configured. When I use again my own computer I will update all data with config.xml and the prove. Ty Adarsh
– mohamet monte
Jun 9 '16 at 12:36
I will try but I thinked that prove i done and dit not work. And config.xml is configured. When I use again my own computer I will update all data with config.xml and the prove. Ty Adarsh
– mohamet monte
Jun 9 '16 at 12:36
It did not work Adarsh
– mohamet monte
Jun 10 '16 at 7:09
It did not work Adarsh
– mohamet monte
Jun 10 '16 at 7:09
Any error? And did it create a log fine called my-log?
– Adarsh Khatri
Jun 10 '16 at 7:28
Any error? And did it create a log fine called my-log?
– Adarsh Khatri
Jun 10 '16 at 7:28
Yes it create the log
– mohamet monte
Jun 10 '16 at 7:39
Yes it create the log
– mohamet monte
Jun 10 '16 at 7:39
Check your var/log folder
– Adarsh Khatri
Jun 10 '16 at 7:43
Check your var/log folder
– Adarsh Khatri
Jun 10 '16 at 7:43
|
show 4 more comments
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f120158%2fmagento-remove-tax-from-all-products-quote-update%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown