Post by beebee » Wed May 18, 2016 10:05 pm

nguyentai92 wrote:I want remove shipping address, payment address, shipping method, payment method opencart 2.0.3.1. I just want my checkout become simple as step 1 -> step 2 -> step 6.... Hope everybody help, please
You may want to try this:

http://openweb.tech/disable-payment-and ... -checkout/

I just added "return false;" to Disable delivery [in /system/library/cart.php] and it removed it from the checkout page.

BeeBee
When the going gets weird, the weird turn Pro!!


User avatar
New member

Posts

Joined
Thu May 12, 2016 5:13 pm

Post by maguijo » Fri Nov 11, 2016 9:00 am

Here's what worked for me on version 2.3.x

In my theme, on checkout.tpl, I added 'style="display: none;"' to the panel section for shipping method. Like this:

Code: Select all

<div class="panel panel-default" style="display: none;">
   <div class="panel-heading">
            <h4 class="panel-title"><?php echo $text_checkout_shipping_method; ?></h4>
   </div>
   <div class="panel-collapse" id="collapse-shipping-method">
      <div class="panel-body"></div>
    </div>
</div>
THEN, in the jQuery section at the end of the document, find the section that deals with the shipping address button click. Find the part of that code that handles the successful loading of the shipping_method template. It starts with this:

Code: Select all

$.ajax({
         url: 'index.php?route=checkout/shipping_method',
         dataType: 'html',
          complete: function() {
               $('#button-shipping-address').button('reset');
           },
           success: function(html) {
Within that success block, there are five commands that essentially open up the shipping method panel. After those five things, insert this line of code:

Code: Select all

$('#button-shipping-method').trigger('click');
That clicks the shipping method button and then all the code proceeds as planned. By the way, I have all shipping methods disabled except free shipping. Since that's the only method available, it's checked by default. Thus the shipping method gets saved and the checkout process can continue. You can use the language files and other templates to hide the "Free Shipping" on confirmation pages.

For clarity, here is the entire block of code that handles the shipping address button click, with my one line inserted in it on line 52.

Code: Select all

// Shipping Address
$(document).delegate('#button-shipping-address', 'click', function() {
    $.ajax({
        url: 'index.php?route=checkout/shipping_address/save',
        type: 'post',
        data: $('#collapse-shipping-address input[type=\'text\'], #collapse-shipping-address input[type=\'date\'], #collapse-shipping-address input[type=\'datetime-local\'], #collapse-shipping-address input[type=\'time\'], #collapse-shipping-address input[type=\'password\'], #collapse-shipping-address input[type=\'checkbox\']:checked, #collapse-shipping-address input[type=\'radio\']:checked, #collapse-shipping-address textarea, #collapse-shipping-address select'),
        dataType: 'json',
        beforeSend: function() {
            $('#button-shipping-address').button('loading');
        },
        success: function(json) {
            $('.alert, .text-danger').remove();

            if (json['redirect']) {
                location = json['redirect'];
            } else if (json['error']) {
                $('#button-shipping-address').button('reset');

                if (json['error']['warning']) {
                    $('#collapse-shipping-address .panel-body').prepend('<div class="alert alert-warning">' + json['error']['warning'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');
                }

                for (i in json['error']) {
                    var element = $('#input-shipping-' + i.replace('_', '-'));

                    if ($(element).parent().hasClass('input-group')) {
                        $(element).parent().after('<div class="text-danger">' + json['error'][i] + '</div>');
                    } else {
                        $(element).after('<div class="text-danger">' + json['error'][i] + '</div>');
                    }
                }

                // Highlight any found errors
                $('.text-danger').parent().parent().addClass('has-error');
            } else {
                $.ajax({
                    url: 'index.php?route=checkout/shipping_method',
                    dataType: 'html',
                    complete: function() {
                        $('#button-shipping-address').button('reset');
                    },
                    success: function(html) {
                        $('#collapse-shipping-method .panel-body').html(html);

                        $('#collapse-shipping-method').parent().find('.panel-heading .panel-title').html('<a href="#collapse-shipping-method" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><?php echo $text_checkout_shipping_method; ?> <i class="fa fa-caret-down"></i></a>');

                        $('a[href=\'#collapse-shipping-method\']').trigger('click');

                        $('#collapse-payment-method').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_payment_method; ?>');
                        $('#collapse-checkout-confirm').parent().find('.panel-heading .panel-title').html('<?php echo $text_checkout_confirm; ?>');

                        $('#button-shipping-method').trigger('click');

                        $.ajax({
                            url: 'index.php?route=checkout/shipping_address',
                            dataType: 'html',
                            success: function(html) {
                                $('#collapse-shipping-address .panel-body').html(html);
                            },
                            error: function(xhr, ajaxOptions, thrownError) {
                                alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
                            }
                        });
                    },
                    error: function(xhr, ajaxOptions, thrownError) {
                        alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
                    }
                });

                $.ajax({
                    url: 'index.php?route=checkout/payment_address',
                    dataType: 'html',
                    success: function(html) {
                        $('#collapse-payment-address .panel-body').html(html);
                    },
                    error: function(xhr, ajaxOptions, thrownError) {
                        alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
                    }
                });
            }
        },
        error: function(xhr, ajaxOptions, thrownError) {
            alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
        }
    });
});


Newbie

Posts

Joined
Sat May 19, 2012 12:18 am

Post by 27eleven » Tue Jan 17, 2017 5:38 pm

Thank you maguijo. Works for me.

I try to disable the payment method too, but i need to copy the "text_agree" function in the last step (confirm.tpl). Do you have any idea?

Working on Opencart Version 2.3.0.2


User avatar
New member

Posts

Joined
Tue Sep 20, 2016 1:05 pm
Location - Switzerland

Post by dalibor » Tue Nov 07, 2017 7:33 am

This extension will skip shipping method if there is only one shipping method https://www.opencart.com/index.php?rout ... n_id=32375

New member

Posts

Joined
Fri Mar 14, 2014 6:12 am
Who is online

Users browsing this forum: No registered users and 12 guests