Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Create an observer for controller_action_layout_generate_blocks_after, the method should look something like this:</p> <p>Note: this is the main idea, the difficult part is to parse the rule, probably it's much easier to add in the rule description something like: productSku: 123; productSku: 345 and to parse the rule description to see if one of the cart products matches the rule or not.</p> <pre><code>public function addPromotionBlock($observer) { $action = $observer-&gt;getEvent()-&gt;getAction(); $layout = $observer-&gt;getEvent()-&gt;getLayout(); if($action-&gt;getRequest()-&gt;getControllerName() == 'cart' &amp;&amp; $action-&gt;getRequest()-&gt;getActionName() == 'index') { $addPromotion = false; $quote = Mage::getSingleton('checkout/cart')-&gt;getQuote(); $items = Mage::getSingleton('checkout/cart')-&gt;getQuote()-&gt;getAllItems(); $rules = Mage::getResourceModel('salesrule/rule_collection') -&gt;setValidationFilter( Mage::app()-&gt;getStore($quote-&gt;getStoreId())-&gt;getWebsiteId(), $quote-&gt;getCustomerGroupId(), $quote-&gt;getCouponCode()) -&gt;load(); // see Mage_SalesRule_Model_Validator foreach ($items as $item) { //check if the rules applies foreach ($rules as $rule) { var_dump($rule-&gt;toArray()); } //let's say we found a valid rule $addPromotion = true; } if ($addPromotion) { $crosssell = $layout-&gt;getBlock('checkout.cart.crosssell'); if ($crosssell) { //set your template here $crosssell-&gt;setTemplate('checkout/promotion.phtml'); } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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