0

I would like to know if, after some conditions are met in a customers cart, it is possible for me to create a 'temporary' shopping cart price rule for that specific cart instance only?

For example- a customer uses a discount code in the cart, but I want to give this specific cart instance another 10% off. However, I don't want to create a "global" shopping cart price rule that will apply to other customers who are checking out around the same time.

Is this feasible? If the nature of shopping cart rules is that they exist irrespective of a shopping cart instance, then is it possible to modify the cart total/shipping/etc manually?

Thank you for your suggestions!

2

Shopping cart rules uses conditions tree. You can expand it to accept customer attributes, like ID or email as it is done in the Enterprise edition. So you can create a global rule, but dedicated to one customer only by the rule condition.

To add new conditions type you need to observe the event salesrule_rule_condition_combine with the listener like

 public function handleNewConditions($observer)
    {
        $transport = $observer->getAdditional();
        $cond = $transport->getConditions();
        if (!is_array($cond)){
            $cond = array();
        }

        $types = array(
            'customer' => 'Customer attributes',
             //... other types are also possible
        );

        foreach ($types as $typeCode => $typeLabel){
            $condition           = Mage::getModel('amasty/rule_condition_' . $typeCode);
            $conditionAttributes = $condition->loadAttributeOptions()->getAttributeOption();

            $attributes = array();
            foreach ($conditionAttributes as $code=>$label) {
                $attributes[] = array(
                    'value' => 'amrules/rule_condition_'.$typeCode.'|' . $code, 
                    'label' => $label,
                );
            }         
            $cond[] = array(
                'value' => $attributes, 
                'label' => Mage::helper('amasty')->__($typeLabel), 
            );          Then           }


        $transport->setConditions($cond);

        return $this; 
    }        

Than you need to extend Mage_Rule_Model_Condition_Abstract and implement the required functions.

0

Your question is a little confusing, but from what I gather this could easily be achieved with the single coupon code. For example, your coupon code is for 15% to the customer, but in the backend the discount is 25%.

You do some simple frontend cosmetic display (if you need to announce the customer is getting an extra 10%), if this discount code is used display message "you just earned an extra 10% off!"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.