News:

Looking for documentation? Take a look on our wiki

Main Menu

Shipment plugin custom JQuery problem

Started by cmsdev, September 28, 2022, 15:24:13 PM

Previous topic - Next topic

cmsdev

I'm using latest stable of Joomla and VM 3.x

I'm trying to use the following Jquery code in my shipment plugin:


$document = JFactory::getDocument();
                    $document->addScriptDeclaration('
                       jQuery(document).ready(function($) {
                        var $checkbox = $("#STsameAsBTjs");
                        if($("#shipment_id_'.$this->_currentMethod->virtuemart_shipmentmethod_id.'").prop("checked")) {
                            //alert("its checked");
                            $checkbox.prop("checked", false);
                            }
                       });
                    ');


The idea is simple: if selected current shipment method then uncheck "Same as Billing" checkbox.

The code works, but only if the plugin's method is selected on the cart page reload. When clicking on the other methods and back to the plugin's one nothing happens. So I have two main questions:

1. How to make that code works every time user clicked on corresponding shipment method?

2. How to dynamically update the cart from custom Jquery code in a way it updates when selecting shipment/payment methods? For example, when "Same as Billing" checkbox unchecked by my code there is no shipping address showing below, but after change shipping/payment method cart updates and I see shipping address after that. I looked at dynupdate.js but can't figure out how to use Virtuemart.updForm in my code.

Appreciate any help with this :)