Documentation - Auto-Choose Shipping/Payment

Auto-Choose Shipping/Payment

If your store is planning to support only ONE shipping option and ONE payment option, then these are some tricks you can use to have those options automatically chosen during the checkout process, making your checkout process faster for the customer.

You have 2 options.

A. Fully Automatic: Set the code up to auto-choose when there is only 1 option for shipping and/or payment. This means that in normal checkout, when the shipping page is loaded, the code will check if there is only one shipping option. If there is, then force it and redirect automatically to the payment page. The same check will be done on the payment page and redirect to the confirmation page. All this will be done in the background so it will look like your customer goes from the checkout button directly to the confirmation page, speeding up your checkout process. If you enable more than 1 payment or shipping later, there is nothing to worry about. The code is smart enough to disable itself and allow the customer to choose if there are more than one.

OR

B. Partially Automatic: Set the code to only select the default radio box, but still require the customer to click the "continue" button. (THIS IS SET BY DEFAULT IN v1.4.8 & LATER)

 

Fully Automatic Modification Steps (Guest Checkout) v1.3.4 - 1.4.9.x:

1. EDIT: catalog/controller/checkout/guest_step_2.php

2. FIND:

$this->session->data['payment_methods'] = $method_data; 

3. AFTER, ADD:


 

		//Q: Autochoose if only 1 shipping and 1 payment to speed up checkout.
		if (count($quote_data) == 1 && count($method_data) == 1) {
			$values = array_values($quote_data);
			if (count($values[0]['quote']) == 1) {
			  	
			  	//shipping
				$keys = array_keys($values[0]['quote']);
				$method = $values[0]['quote'][$keys[0]];
				$this->session->data['shipping_method'] = $method;
				$this->session->data['comment'] = (isset($this->session->data['comment'])) ? $this->session->data['comment'] : '';
				
				//payment
				$keys = array_keys($method_data);
				$values = array_values($method_data);
				$method = $values[0];
				$this->session->data['payment_method'] = $method;
				$this->session->data['comment'] = (isset($this->session->data['comment'])) ? $this->session->data['comment'] : '';			  
			  	$this->redirect(HTTPS_SERVER . 'index.php?route=checkout/guest_step_3');
			}
		}//



Fully Automatic Modification Steps (Registered Checkout) v1.3.4 - 1.4.9.x

:

1. EDIT: catalog/controller/checkout/shipping.php

2. FIND:

$this->session->data['shipping_methods'] = $quote_data;

3. AFTER, ADD:


 

			//Q: Autochoose shipping if using only one and it's single rate
			if (count($quote_data) == 1) {
			   $values = array_values($quote_data);
			   if (count($values[0]['quote']) == 1) {
			      $keys = array_keys($values[0]['quote']);
			      $method = $values[0]['quote'][$keys[0]];
			      $this->session->data['shipping_method'] = $method;
			      $this->session->data['comment'] = (isset($this->session->data['comment'])) ? $this->session->data['comment'] : '';
			      $this->redirect(HTTPS_SERVER . 'index.php?route=checkout/payment');
			   }
			}//



 

4. EDIT: catalog/controller/checkout/payment.php (NOTE: If you bypass both shipping and payment, you won't be able to enter comments and in 1.4.8 you won't be able to enter a coupon since the coupon is on the payment page. So you may not want to complete steps 5 & 6 of this one. In 1.4.9 the coupon box has been added to the confirmation page as well as the payment page, but you still won't have comments)

 

5. FIND:

$this->session->data['payment_methods'] = $method_data;

6. AFTER, ADD:


 

		// If there is only one payment option, set it to session and go to confirm
		if (count($method_data) == 1) {
		   $keys = array_keys($method_data);
		   $values = array_values($method_data);
		   $method = $values[0];
		   $this->session->data['payment_method'] = $method;
		   $this->session->data['comment'] = (isset($this->session->data['comment'])) ? $this->session->data['comment'] : '';
		   $this->redirect(HTTPS_SERVER . 'index.php?route=checkout/confirm');
		}

 


 

Partially Automatic Modification Steps (Guest Checkout) v1.3.4 - 1.4.9.x

:

1. EDIT: catalog/view/theme/default/template/checkout/guest_step_2.tpl

2. FIND:

<?php if ($quote['id'] == $shipping) { ?>

3. REPLACE WITH:

<?php if (@$quote['id'] == $shipping|| !$shipping) { ?>
<?php $shipping= $quote['id']; ?>

4. FIND:

<?php if ($payment_method['id'] == $payment) { ?>

5. REPLACE WITH:

<?php if ($payment_method['id'] == $payment|| !$payment) { ?>
<?php $payment= $payment_method['id']; ?>

 

Partially Automatic Modification Steps (Registered Checkout) v1.3.4 - 1.4.9.x

:

1. EDIT: catalog/view/theme/default/template/checkout/shipping.tpl

2. FIND:

<?php if ($quote['id'] == $shipping) { ?>

3. REPLACE WITH:

<?php if (@$quote['id'] == $shipping|| !$shipping) { ?>
<?php $shipping= $quote['id']; ?>

4. EDIT: catalog/view/theme/default/template/checkout/payment.tpl

5. FIND:

<?php if ($payment_method['id'] == $payment) { ?>

6. REPLACE WITH:

<?php if ($payment_method['id'] == $payment|| !$payment) { ?>
<?php $payment= $payment_method['id']; ?>
Ce site est maintenu par l'agence ONLYTECH spécialisée en création de sites e-commerce
Découvrez de nouveaux tutoriaux et ressources pour le développement Web sur www.ressources-du-web.com
L'actualité High-tech et Web sur www.passion-hitech.info