How to remove delivery shipping step on prestashop 1.6.1?

六月ゝ 毕业季﹏ 提交于 2019-12-07 12:32:28

问题


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 ?


回答1:


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.




回答2:


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');



来源:https://stackoverflow.com/questions/32475736/how-to-remove-delivery-shipping-step-on-prestashop-1-6-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!