简体   繁体   中英

Lemonstand: Skip shipping method in checkout

A client will always have free shipping for all of their products sold through their Lemonstand store, so they want the Shipping Method step removed from the checkout, as it would be an unnecessary extra click for the user. And since it's a free shipping on every item regardless, they didn't want to have to set a unique 'free shipping' option on every product in the store, which would also be laborious.

Initially I simply removed and unset() the shipping_method value from my checkout;progress.php partial, like so:

<?php 
$steps = array(
    'billing_info'      => 'Billing info',
    'shipping_info'     => 'Shipping info',
    //'shipping_method' => 'Shipping method',
    'payment_method'    => 'Payment method',
    'review'            => 'Order review'
);

unset($steps['shipping_method']);

?>

(The unset is in place because Lemonstand has a tendency to overwrite these values based on the product types in the checkout process)

However, this results in an error during checkout: "Please select a shipping method" - which makes sense, as we're not setting it to anything. Any ideas on how to skip this step and set a default shipping method?

It turns out that this can be achieved with a single line of PHP, which I added to the checkout;payment_method.php partial, including the above steps to remove the Shipping Method step from the checkout.

First off, I created a table rate shipping option, with the Country, State, & City all set to * (wildcard), and a cost of 0 . Then I gave it an API code of default .

In the checkout;payment_method.php partial, I added the following line:

Shop_CheckoutData::set_shipping_method(Shop_ShippingOption::find_by_api_code('default')->id);

This way, the Shipping Method step is removed from the customer-facing checkout process, but shipping is still automatically selected and calculated during checkout.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM