K
K
kentos2021-08-05 04:24:10
opencart
kentos, 2021-08-05 04:24:10

How to remove the reboot of the delivery block?

Hello, the question is this, I installed the Omniva delivery module, and tried to integrate it into simplecheckout.
But after choosing a delivery, when you make an order, the field is reloaded, and the choice of this delivery disappears, that is, it cannot be selected in any way.

here is the code

<?php
        // Omniva (skip terminal locations)
        if (strpos($quote['code'], 'omnivalt.parcel_terminal') !== false) {
          continue;
        } else if (strpos($quote['code'], 'fake.parcel_terminal') !== false) {
          ?>
          <script>
        $(document).ready(function () {
      var omnivaModuleReady = false;
      $(document).on('click', 'input[type="radio"][name="shipping_method"]', function (e) {
          console.log($(this).val());
        if ($(this).val() === 'fake.parcel_terminal' && !omnivaModuleReady) {
            omnivaModuleReady = $(this).omniva({
                country_code: '<?php echo $omni_country_code;?>',
                path_to_img: 'image/omniva/',
                callback: function (id) {
                  omnivaModuleReady.val('omnivalt.parcel_terminal_' + id);
                },
                translate: omniva_map_translation,
                terminals: <?php echo json_encode($omni_terminals);?>,
            });
            omnivaModuleReady.trigger('omniva.show');

            // with default template this should be enough even if user changes postcode (as he needs to press continue button)
            var sameShipping = $('input[name="shipping_address"]');
            if (sameShipping.length > 0 && sameShipping.is(':checked')) {
                omnivaModuleReady.trigger('omniva.postcode', [$('#input-payment-postcode').val()]);
            } else {
                omnivaModuleReady.trigger('omniva.postcode', [$('#input-shipping-postcode').val()]);
            }
        } else {
            if (omnivaModuleReady) {
              if ($(this).is(omnivaModuleReady)) {
                  omnivaModuleReady.trigger('omniva.show');
              } else {
                  omnivaModuleReady.trigger('omniva.hide');
              }
            }
        }
      });
      $('input[type="radio"][name="shipping_method"]:checked').click();
      $('#button-shipping-method').on('click', function (e) {
        var $selectedOption = $('input[type="radio"][name="shipping_method"]:checked');
        if ($($selectedOption).val().includes('fake.parcel')) {
          e.preventDefault();
          e.stopPropagation();
          alert(omniva_map_translation.terminal_not_selected);
        }
      });
    });
    </script>
          <?php
        }
        // Omniva END
        ?>


Inserted after <?php foreach ($shipping_method['quote'] as $quote) { ?>

Version opencart 2.3

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question