Been searching high and low for a question similar to this both here and in Google and I’m surprised that I haven’t been able to find anything similar.
I’m familiar with Customer Groups and Tiered Pricing but it doesn’t fit the objective that my client has set.
What we want is for a user to come to our Magento store and see the regular homepage with regular prices. At that point we want a prominent text field for the user to add a Coupon Code upon which the site will refresh and display the new discounted prices with the regular price struck out (or “slashed” by some other visual method.
Customer Groups / Tiered Pricing aren’t the solution because they require that the customer log in. The NOT LOGGED IN group wouldn’t help either since all users would see the discount.
This can’t happen in the Shopping Cart either because by then it’s too late, this needs to happen on the Catalog level.
We are currently using OSCommerce and transitioning over to Magento shortly. Right now what we’re doing to emulate this behavior is to have a text field on our regular website on the Store Access page where a user can click on a region or enter a coupon code. IF they enter a code they are redirected to a custom store that has special pricing.
I know that it’s easy to recreate our current method in Magento by creating a store view and then using the same functionality but it seems a shame to do this when the idea of moving to a new platform that so much more powerful.
I haven’t seen any extensions that do this. Does anyone have any insight as to whether something like this can be accomplish and if so, how?
2
Answers
This can definitely be achieved. It involves writing a custom module (start here and here) with a controller that accepts the value of your coupon field, initiates a checkout session for that user (
$session = Mage::getSingleton('checkout/session')
) and stores the coupon code in the checkout session ($session->setData('coupon_code',$coupon
).You would then extend the price model to check for coupon code in the session. You can override
Mage_Catalog_Model_Product_Type_Price
in your own module using the<rewrite>
syntax. Retrieve the coupon code ($couponCode = Mage::getSingleton("checkout/session")->getData("coupon_code");
). Note that the Price object is different for Bundle and other non-Simple product types.If you need more info, I can post code samples.
I am curious Jonathon how you did it, I didn’t take your approach, mine is a little more complex. Mine does allow someone to post the coupon code in the url as well though and I set a cookie and all that for it. I basically setup my own form in the header that a user can put in a coupon code and have that applied as well as putting the coupon in the url for email campaigns.
It would take me a while to go back over it in detail, so I will post some code snippets that maybe can help you get going, a long with trying the way Jonathan says as well.
Override the cart controller and add your own action.
I also had to override the couponPostAction() to get things to work the normal way correctly.
I have an addCoupon method in my own model
Validating the coupon
I extended
Mage_SalesRule_Model_Validator
with my own validator functionHere I generate the json response
I also had to override the collect method in
Mage_SalesRule_Model_Quote_Discount