Link to a specific step in onepage checkout

后端 未结 4 786
自闭症患者
自闭症患者 2020-12-29 15:51

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

相关标签:
4条回答
  • 2020-12-29 16:26

    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.

    0 讨论(0)
  • 2020-12-29 16:30

    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; ?>');
    
    0 讨论(0)
  • 2020-12-29 16:32

    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.

    0 讨论(0)
  • 2020-12-29 16:33

    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');
        });
    
    0 讨论(0)
提交回复
热议问题