it’s possible to remove or add a step to onepage checkout, but as you’ve seen, it’s not easy because steps are linked between them, so you must study php and js files and take some hours to success
(sorry for my bad english )
for the shipping method, i think you can insert a test in template/checkout/onepage/shipping_method.phtml after have identified the good shipping method id in database
hope that helps a bit
class Mage_Checkout_Block_Onepage_Coupon extends Mage_Checkout_Block_Onepage_Abstract { protected function _construct() { $this->getCheckout()->setStepData('coupon', array( 'label' => Mage::helper('checkout')->__('Coupon Information'), 'is_show' => $this->isShow() ));
parent::_construct(); }
public function getMethod() { return $this->getQuote()->getCheckoutMethod(); } }
/app/design/frontend/default/<theme>/template/checkout/onepage/coupon.phtml
create a template, like billing.phtml
/app/code/core/Mage/Checkout/Block/Onepage/Progress.php Don’t know if needed but add
public function getCoupon() { return $this->getQuote()->getShippingAddress(); }
/app/code/core/Mage/Checkout/controllers/OnepageController.php
It is imporant to set in one step the goto_section to “coupon” to get there… additionally you need a new function to save or at least go to the next step
public function saveCouponAction() { $this->_expireAjax(); if ($this->getRequest()->isPost()) { $result['goto_section'] = 'shipping_method'; $this->getResponse()->setBody(Zend_Json::encode($result));
/skin/frontend/default/<theme>/js/opcheckout.js
tricky part: I copied the Billing class and renamed it to Coupon. Still i got some troubles and so I did in coupon.phtml
I’ll chuck my lot in here, right now I don’t have time to edit my noets, but feel free to read them unedited! This is me adding the ability to add a delivery date step to the onepage checkout, these are my condensed notes, if you want the full ones feel free to PM me.
By the way, this isn’t code, but I use notepad for note taking so I’m using the code view to preformat my text…
Also, this doesn’t update the right hand “progress” box yet…
core/Mage/Checkout/Block/Onepage.php -- add your step into the $stepCodes array
* core/Mage/Checkout/Block/Onepage/Deliverydate.php -- Copy Billing.php as a base, and remove all methods except for _construct() -- Change setStepData, changing billing to deliverydate
* template/checkout/onepage/deliverydate.phtml -- Copied billing.phtml, remove the fat and rename billing to deliverydate -- Add an input with name and id delivery_date
* layout/checkout.xml -- I added this node, right after the onepage_shipping node: <block type="checkout/onepage_deliverydate" name="checkout.onepage.deliverydate" as="deliverydate" template="checkout/onepage/deliverydate.phtml"/>
* core/Mage/Checkout/controllers/Onepage.php -- Add a method saveDeliverydateAction(), copy it from saveShippingMethodAction(), do this to it: --- Mage::dispatchEvent('checkout_controller_onepage_save_shipping_method'...(etc) --- $this->getResponse()->setBody(Zend_Json::encode($result)) -- Change the getpost and result lines: --- $data = $this->getRequest()->getPost('delivery_date', ''); --- $result = $this->getOnepage()->saveDeliverydate($data);
* core/Mage/Checkout/Model/Type/Onepage.php -- Add a method saveDeliverydate(), copy it from saveShippingMethod(), do this to it: --- change the argument from $shippingMethod to $data, do this throughout function --- get rid of these lines ---- $rate = ..(etc) ---- the entire if ($!rate) statement ---- $this->getQuote()->getShippingAddress()->setShippingMethod($shippingMethod); --- Change $this->getQuote()->collectTotals()->save(); to $this->getQuote()->save(); --- Add this line, below the if(empty($data) conditional: ---- $this->getQuote()->getShippingAddress()->setDelivery_date($data); --- Change the $this->getCheckout() part to: ---- ->setStepData('deliverydate', 'complete', true)->setStepData('shipping_method', 'allow', true);
* js/opcheckout.js -- Add your step to this.steps (inside Checkout.prototype) -- create setDeliverydate() (inside Checkout.prototype), copy from setShipping() -- Alter any gotoSection()'s from 'shipping_method' to 'deliverydate' (should be in setBilling() & setShipping()) -- Create Deliverydate() in the root, copy from ShippingMethod(), make changes: --- change save()'s checkout.setLoadWaiting to ('deliverydate'); --- I commented out the calidation, keep it or not... --- I copied nextStep() from Shipping, it seemed more generic, then I changed checkout.setStepResponse(response); to checkout.setDeliverydate();
Hi. I’m pretty new to magento, but am attempting to add a step to checkout. I almost have it completed and working and will outline the steps that I took to get to that point.
1. Figure out what the step involves adding and name them. I tried to keep the name consistent, it’s important because of the __call magic method that magento uses to set properties.
2. Add each one of the attributes to magento_eav_attributes. You are going to have to figure out what entity type it is you are adding. What I did was picked one of the payment ones and copied most of it changing the little data that I needed.
3. Create new columns for each of the attributes in the magento_sales_flat_quote, or other appropriate flat table. Keep the names consistent.
4. Add the fields to the array in Sales/Model/Entity/Setup.php. (Not really sure where I’m trying to shoehorn them into quote and orders).
5. Add fields to array in Sales/Model/Mysql4/Setup.php. (Again not really sure about this step).
6. Add to Sales/etc/config.xml.
7. Override the controller. There are other forum posts on here explaining how to override a controller. Following them worked for me. The important thing to remember is that you can’t just throw controllers in the local directory to override them. I didn’t have too much trouble with this step. You have to extend Mage_Checkout_OnepageController and add a method saveStepnameAction(). If you look at the other examples such as billing and shipping it should help out.
8. Make a new local Checkout Block.
This is a php file that you will create in /code/local/Mage/Checkout/Block/Onepage/. You need to write a class that extends Mage_Checkout_Block_Onepage_Abstract.
class Mage_Checkout_Block_Onepage_Stepname extends Mage_Checkout_Block_Onepage_Abstract { public function __construct() { $this->getCheckout()->setStepData('stepname', array( 'label' => 'Step label', 'is_show' => $this->isShow()) ); parent::__construct(); } public function getMethod() { return $this->getQuote()->getCheckoutMethod(); } }
9. Override the Onepage Checkout Model.
This involves copying over the /code/core/Mage/Checkout/Model/Type/Onepage.php to /code/local/Mage/Checkout/Model/Type/Onepage.php.
You need to add a new method. I followed most of the directions in the previous post, but had to add some magic methods to actually get it to set the data.
You can method chain others onto that, the format set/getWhatever will call the magic method __call to set/get properties.
These are the steps that I have taken, not including the progress widget. The point I am at now has data being saved to the flat table, but not to the eav table. I am not sure exactly what I am doing wrong, but if anyone has some suggestions it would be appreciated.
EDIT: I was wrong. What I outlined above works perfectly for me. The problem was I was looking for the saved data in the wrong table. I expected it to show up in magento_sales_order_entity_varchar and it is showing up in magento_sales_order_varchar.
But I’m only redirected on the onepagecheckout on the first step , without message success or unsuccess, and if i go back to the cart, there is the message…
I am trying to do this through a module instead of hacking these file, and I was able to add the stepcode but now I am not sure waht has to go inside of config.xml so that onepage.php can pull the stepData
I’ll chuck my lot in here, right now I don’t have time to edit my noets, but feel free to read them unedited! This is me adding the ability to add a delivery date step to the onepage checkout, these are my condensed notes, if you want the full ones feel free to PM me.
By the way, this isn’t code, but I use notepad for note taking so I’m using the code view to preformat my text…
Also, this doesn’t update the right hand “progress” box yet…
core/Mage/Checkout/Block/Onepage.php -- add your step into the $stepCodes array
* core/Mage/Checkout/Block/Onepage/Deliverydate.php -- Copy Billing.php as a base, and remove all methods except for _construct() -- Change setStepData, changing billing to deliverydate
* template/checkout/onepage/deliverydate.phtml -- Copied billing.phtml, remove the fat and rename billing to deliverydate -- Add an input with name and id delivery_date
* layout/checkout.xml -- I added this node, right after the onepage_shipping node: <block type="checkout/onepage_deliverydate" name="checkout.onepage.deliverydate" as="deliverydate" template="checkout/onepage/deliverydate.phtml"/>
* core/Mage/Checkout/controllers/Onepage.php -- Add a method saveDeliverydateAction(), copy it from saveShippingMethodAction(), do this to it: --- Mage::dispatchEvent('checkout_controller_onepage_save_shipping_method'...(etc) --- $this->getResponse()->setBody(Zend_Json::encode($result)) -- Change the getpost and result lines: --- $data = $this->getRequest()->getPost('delivery_date', ''); --- $result = $this->getOnepage()->saveDeliverydate($data);
* core/Mage/Checkout/Model/Type/Onepage.php -- Add a method saveDeliverydate(), copy it from saveShippingMethod(), do this to it: --- change the argument from $shippingMethod to $data, do this throughout function --- get rid of these lines ---- $rate = ..(etc) ---- the entire if ($!rate) statement ---- $this->getQuote()->getShippingAddress()->setShippingMethod($shippingMethod); --- Change $this->getQuote()->collectTotals()->save(); to $this->getQuote()->save(); --- Add this line, below the if(empty($data) conditional: ---- $this->getQuote()->getShippingAddress()->setDelivery_date($data); --- Change the $this->getCheckout() part to: ---- ->setStepData('deliverydate', 'complete', true)->setStepData('shipping_method', 'allow', true);
* js/opcheckout.js -- Add your step to this.steps (inside Checkout.prototype) -- create setDeliverydate() (inside Checkout.prototype), copy from setShipping() -- Alter any gotoSection()'s from 'shipping_method' to 'deliverydate' (should be in setBilling() & setShipping()) -- Create Deliverydate() in the root, copy from ShippingMethod(), make changes: --- change save()'s checkout.setLoadWaiting to ('deliverydate'); --- I commented out the calidation, keep it or not... --- I copied nextStep() from Shipping, it seemed more generic, then I changed checkout.setStepResponse(response); to checkout.setDeliverydate();
I just added discount coupon section to checkout page for my customer. I put it in review order and use ajax to apply or cancel discount without returing shopping cart. You can see at his site: http://homemedexpress.com/
If someone is interested in this, let me know, I will package it as an free extension and send to you.
Best Regards, Neo.
I just added discount coupon section to checkout page for my customer. I put it in review order and use ajax to apply or cancel discount without returing shopping cart. You can see at his site: http://homemedexpress.com/
If someone is interested in this, let me know, I will package it as an free extension and send to you.
Best Regards, Neo.
I wan to see it.. !! Looking forward to the extension!
I just added discount coupon section to checkout page for my customer. I put it in review order and use ajax to apply or cancel discount without returing shopping cart. You can see at his site: http://homemedexpress.com/
If someone is interested in this, let me know, I will package it as an free extension and send to you.
Best Regards, Neo.
I am interested in this, could you send me your extension please?
Also, I looked at your site. Very nice! I notice you organize by brands, was that custom code or did you treat the brands as categories?
Where are you hosting this? It seems very slow, too bad for a nice design.