mttetc
mttetc

Reputation: 745

How to remove delivery shipping step on prestashop 1.6.1?

I'm new to prestashop and I'm having major trouble removing the delivery shipping step because I only sell virtual products. I am using prestashop 1.6.1.

I know I have to modify order-carrier.tpl file and have followed several posts here and there but couldn't get it done right.

Does any of you have any actual idea on how to do this ?

Upvotes: 3

Views: 7651

Answers (2)

Leothil
Leothil

Reputation: 66

Bonjour, here is what i did

Override AdminOrderPreferencesController and add a boolean configuration field to toggle this functionnality

$this->fields_options = array(
    [...]
    'PS_ORDER_PROCESS_BYPASS_SHIPPING' => array(
        'title' => $this->l('Bypass shipping step'),
        'hint' => $this->l('Do not show shipping step in order process.'),
        'validation' => 'isBool',
        'cast' => 'intval',
        'type' => 'bool'
    )
);

You can now find a toggle button in Backoffice under Preferences > Orders


Override OrderController and add an if in init() method to set the current step to payment step if the controller inits itself on delivery step

public function init()
{
    global $orderTotal;

    parent::init();

    $this->step = (int)Tools::getValue('step');

    // HERE IT IS
    if((bool)Configuration::get('PS_ORDER_PROCESS_BYPASS_SHIPPING') && $this->step == self::STEP_DELIVERY){
        $this->step = self::STEP_PAYMENT;
    }

    if (!$this->nbProducts) {
        $this->step = -1;
    }

Also bypass the CGV checking verification on payment step in initContent() method.
If you don't, CGV will never be checked, it will redirect you on delivery step, you will tell him that he is in fact on payment step, he will check for CGV again, he will do the same redirection ... and you are in an infinite loop

case OrderController::STEP_PAYMENT:
    $cgv = Tools::getValue('cgv') || $this->context->cookie->check_cgv;

    if (
        !(bool)Configuration::get('PS_ORDER_PROCESS_BYPASS_SHIPPING') && // HERE IT IS
        $is_advanced_payment_api === false && Configuration::get('PS_CONDITIONS')
        && (!Validate::isBool($cgv) || $cgv == false)
    ) {
        Tools::redirect('index.php?controller=order&step=2');
    }

Pass the configuration parameter to the view to modify display

$this->context->smarty->assign('bypass_shipping_step', (bool)Configuration::get('PS_ORDER_PROCESS_BYPASS_SHIPPING'));

And in your views, do you styling stuff with some if
In order-steps.tpl you can add an {if not $bypass_shipping_step}...{/if} around the fourth li to hide it, and do something like :

{if $bypass_shipping_step}
<style>
    ul.step li{
        width:25%;
    }
</style>
{/if}

or import a dedicated stylesheet which would be cleaner.


Hope it helped.

Upvotes: 4

tarek fellah
tarek fellah

Reputation: 367

In shopping-cart.tpl, remove call to order-carrier.tpl. If you are not using one pagecheckout, in orderController.php, you have to change all redirection to step 2 (shipping method choosing), to redirection step 3 Tools::redirect('index.php?controller=order&step=2'); to Tools::redirect('index.php?controller=order&step=3');

Upvotes: 1

Related Questions