Skip to content

Updates to checkout.php for Web Store 3.2.2

James Pickard edited this page Feb 12, 2015 · 1 revision

As part of Web Store 3.2.2 we made some changes to the single-page checkout code. Custom themes with a modified checkout.php should be updated to use the new code. Stores using a stock theme and themes that do not override checkout.php are unaffected.

We recommend against customizing the checkout. For more information see https://github.com/lightspeedretail/webstore/wiki/Checkout

Backwards compatibility for customized themes has been included in 3.2.2 and will be removed in 3.2.3. Custom themes containing checkout.php should be updated before upgrading to 3.2.3.

The following changes are required to update checkout.php:

  1. Find references to:

    updateShippingAuto()
    

    And replace with:

    singlePageCheckout.updateShippingAuto()
    
  2. Find references to:

    updateTax(data):
    

    And replace with:

    singlePageCheckout.updateTax(data)
    
  3. Find references to:

    updateCart(this.value)
    

    And replace with:

    singlePageCheckout.updateCart(this.value)
    
  4. Find references to:

    changePayment(this.value)
    

    And replace with:

    singlePageCheckout.changePayment(this.value)
    
  5. Find references to:

    updateShippingPriority(this.value)
    

    And replace with:

    singlePageCheckout.pickShippingProvider(this.value)
    
  6. Find the following section:

    <?php echo CHtml::ajaxButton (
    	Yii::t('checkout','Calculate Shipping'),
    	array('cart/ajaxcalculateshipping'),
    	array('type'=>"POST",
    		'dataType'=>'json',
    		'data'=>'js:jQuery($("#checkout")).serialize()',
    		'onclick'=>'js:jQuery($("#shippingSpinner")).show(),
                           js:jQuery($("#' . CHtml::activeId( $model, 'shippingProvider') .'")).html(\'\'),
                           js:jQuery($("#' . CHtml::activeId( $model, 'shippingPriority') .'")).html(\'\')',
    		'success' => 'js:function(data){
                               if (data.result=="error") alert(data.errormsg);
    						savedShippingProviders = data.provider;
    						savedShippingPrices = data.prices;
    						savedTaxes = data.taxes;
    						savedTotalScenarios = data.totals;
    						savedShippingPriorities = data.priority;
    						savedCartScenarios = data.cartitems;
    						savedPickedModule = $("#' . CHtml::activeId( $model, 'paymentProvider') .'").val();
    						$("#' . CHtml::activeId( $model, 'shippingProvider') .'").html(data.provider);
                                     $("#' . CHtml::activeId( $model, 'shippingPriority') .'").html(data.priority);
                                     $("#' . CHtml::activeId( $model, 'paymentProvider') .'").html(data.paymentmodules);
                                     $("#' . CHtml::activeId( $model, 'paymentProvider') .'").val(savedPickedModule);
    						$("#shippingSpinner").hide();
                                     $("#shippingProvider_0").click();
                                     }',
    	), array('id'=>'btnCalculate'));
    ?>
    

    And replace with:

    <input type="button" id="btnCalculate" value="<?= CHtml::encode(Yii::t('checkout', 'Calculate Shipping')); ?>">
    <?php
    	Yii::app()->clientScript->registerScript(
    		'btnCalculate-script',
    		'$("#btnCalculate").click(singlePageCheckout.calculateShipping.bind(singlePageCheckout))',
    		CClientScript::POS_LOAD
    	);
    ?>
    
  7. At the end of the file replace

    //Render javascript
    echo $this->renderPartial('/cart/_cartjs',array('model'=>$model),true);
    

    With

    $this->renderPartial(
    	'ext.wssinglepagecheckout.views.instantiate',
    	array(
    		'model' => $model
    	)
    );
    
Clone this wiki locally