English 中文(简体)
Link to a specific step in onepage checkout
原标题:

Is it possible to redirect the browser to nth step in the onepage checkout? If so, how would one go about doing it?

I m working on a payment module and have a sort of "cancel" action that i would like to return the user to the step in checkout where you choose the payment method.

I currently return the user to the first step of the checkout like so:

$this->_redirect( checkout/onepage , array( _secure =>true));

Another issue with this is that i does not work all the time, in certain browsers i d really not like to name this sort of works "sometimes". Is that something that is known and/or commonly accepted? I have very little actual information regarding this, but i ve had complaints from customers about this behaviour. They generally won t give me any specifics so it s kind of a dead end.

最佳回答

checkout/onepage.phtml:

In PHP

$step = Mage::app()->getRequest()->getParam( step );
$stepCodes = array( billing ,  shipping ,  shipping_method ,  payment ,  review );

if (($step) && (in_array($step,$stepCodes)) && ($this->getActiveStep() ==  billing )) {
    $checkout = Mage::getSingleton( checkout/type_onepage );
    $checkout->saveBilling(Mage::getSingleton( checkout/session )->getQuote()->getBillingAddress()->toArray(),false);
    $checkout->saveShipping(Mage::getSingleton( checkout/session )->getQuote()->getShippingAddress()->toArray(),false);
    $checkout->saveShippingMethod(Mage::getSingleton( checkout/session )->getQuote()->getShippingAddress()->getShippingMethod());
    $activestep = Mage::app()->getRequest()->getParam( step );
}
else 
if($this->getActiveStep()) {
    $activestep = $this->getActiveStep();
}

In javascript

accordion.openSection( opc-<?php /* edit */ echo $activestep; ?> );
问题回答

Sorry for not being clear. Open the template for the onepage checkout page. It is app/design/frontend/default/default/template/checkout/onepage.phtml In the file add

<?php 
//if (your cancel condition) 
{ 
echo 
 <script type="text/javascript"> 
checkout.gotoSection( checkout-step-review ); 
</script> ; 
}
?> 

This will take the user the to the step you need. You have to decide the condition(s) under which the user is taken to the step.

I wanted to do the same thing, but couldn t figure out how to make the one page checkout open at the payment step.

In the end, I used jQuery and an ajax call so I could call javascript code after changing the page:

    jQuery( body ).load(failure, {}, function () {
        // set the magento onepage checkout accordion to the payment section
        checkout.gotoSection( payment );
    });

Rick is referring to the fact the steps in the checkout are a not RESTful, but Ajaxified steps, they are all on the same page, the vertical accordion is, in fact, just a set of divisions manipulated by a javascript function. You ll need to set the javascript to the proper step as he stated.





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签