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
In excess I'm lethal
Why am I allowed to create multiple unique pointers from a single object?
If Nick Fury and Coulson already knew about aliens (Kree and Skrull) why did they wait until Thor's appearance to start making weapons?
sp_blitzCache results Memory grants
Elegant way to replace substring in a regex with optional groups in Python?
Sending manuscript to multiple publishers
How did people program for Consoles with multiple CPUs?
Is it possible to search for a directory/file combination?
How to count occurrences of text in a file?
What is "(CFMCC)" on an ILS approach chart?
How to safely derail a train during transit?
Multiple labels for a single equation
Which kind of appliances can one connect to electric sockets located in an airplane's toilet?
Why don't programming languages automatically manage the synchronous/asynchronous problem?
How to start emacs in "nothing" mode (`fundamental-mode`)
Does it take more energy to get to Venus or to Mars?
What was the first Unix version to run on a microcomputer?
Preparing Indesign booklet with .psd graphics for print
Is there a way to save my career from absolute disaster?
Why does the UK parliament need a vote on the political declaration?
Can you replace a racial trait cantrip when leveling up?
How did the Bene Gesserit know how to make a Kwisatz Haderach?
How does the mv command work with external drives?
Won the lottery - how do I keep the money?
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 55 mins 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