The first way that comes to mind is:
To create a new first step in the checkout process that would be called each time. When you are returned from the 3rd party page this would have a URL param set so we know to do something. This requires:
Updating: public/app/code/core/Mage/Checkout/Block/Onepage/Abstract.php
protected function _getStepCodes()
{
return array('login', 'billing', 'shipping', 'shipping_method', 'payment', 'review');
}
This block gets the available checkout steps. We would include a new one at the beginning for API
or whatever make sense to what you are doing.
Then in OnePageController.php ( All should be changed in your own module ) we would need a new step:
public function saveAPIAction()
{
$this->_expireAjax();
if ($this->getRequest()->getParam('returned')) {
$result['goto_section'] = 'review';
} else {
$result['goto_section'] = 'login';
}
}
Next up would be to change the JS OpCheckout.js this file will need:
this.steps = ['login', 'billing', 'shipping', 'shipping_method', 'payment', 'review'];
Updating to reflect the new step. As well as a full new class adding for API
var Billing = Class.create();
Billing.prototype = {
initialize: function(form, addressUrl, saveUrl){
this.form = form;
if ($(this.form)) {
$(this.form).observe('submit', function(event){this.save();Event.stop(event);}.bind(this));
}
this.saveUrl = saveUrl;
this.onSave = this.nextStep.bindAsEventListener(this);
this.onComplete = this.resetLoadWaiting.bindAsEventListener(this);
// would need to add forcing payment save or success redirect
}
}
Complexity when it comes to all of the above is ensuring that all the options throughout your checkout journey are set. If when the current implementation returns to the current checkout it just calls payment.save then it should be ok as adding to what I have provided will get you going with a new checkout step that does implement almost the same as the current but in a more modular means. You could add more functionality if required.
Please change code in file : HusseyCoding_AjaxCartPopup_Block_Popup
Find bellow function
public function getCheckoutUrl()
{
return $this->_getCheckoutUrl();
}
And replace below function
public function getCheckoutUrl()
{
//Make sure please put your One step checkout extension module enable or disable condition here
if (!$this->helper('onestepcheckout')->isRewriteCheckoutLinksEnabled()){
return $this->_getCheckoutUrl();
}
return $this->getUrl('onestepcheckout', array('_secure'=>true));
}
Best Answer
Yes this is the file.
This file contains JavaScript class definitions for the following:
For each step you have a
save
method that does several things, including the AJAX call to the controller.For example, for the ShippingMethod, this method looks like this:
When the AJAX call is successfull, the code call the
onSave
binded event listener:The
nextStep
is the method that handle the AJAX response: