MultivendorX Pro
-
AuthorPosts
-
-
June 29, 2023 at 11:33 PM #193925srv46126Participant
Hello,
I have been using a PHP function to auto toggle parent category when child selected and it was working just fine until MVX Pro 1.1.0 came.
So right now the toggler works fine in “generative”, wordpress-woocommerce vendor dashboard (the “backend one”), however in the custom one, one which is bring with MVX it stopped working, can you give me any updates what was changed and why it doesn’t work anymore?Here’s my code:
function super_category_toggler() { $taxonomies = apply_filters('super_category_toggler',array()); for($x=0;$x<count($taxonomies);$x++) { $taxonomies[$x] = '#'.$taxonomies[$x].'div .selectit input'; } $selector = implode(',',$taxonomies); if($selector == '') $selector = '.selectit input'; echo ' <script> jQuery("'.$selector.'").change(function(){ var $chk = jQuery(this); var ischecked = $chk.is(":checked"); $chk.parent().parent().siblings().children("label").children("input").each(function(){ var b = this.checked; ischecked = ischecked || b; }) checkParentNodes(ischecked, $chk); }); function checkParentNodes(b, $obj) { $prt = findParentObj($obj); if ($prt.length != 0) { $prt[0].checked = b; checkParentNodes(b, $prt); } } function findParentObj($obj) { return $obj.parent().parent().parent().prev().children("input"); } </script> '; } add_action('admin_footer-post.php', 'super_category_toggler'); add_action('admin_footer-post-new.php', 'super_category_toggler');
Copy -
June 30, 2023 at 5:35 PM #193961NerdySupportExpert MoumitaKeymaster
Hi, sorry to hear that you have faced some issue.
Can you please explain the flo you are looking for so we can assist you accordingly.
-
July 3, 2023 at 5:39 PM #194025srv46126Participant
Hi,
naturally, let me discuss it on following screenshot:
in the previous version of MVX Pro once a vendor marked “Empire” category as checked, both “Warhammer Age of Sigmar” and “Grand Allience Order” were marked checked automatically. It worked well on both product WordPress backend (so it’s mysite.com/wp-admin/post.php?post=1234&action=edit aswell as in Vendor Dashboard as example mysite.com/dashboard/).After the new MVX Pro update it stopped working in Vendor Dashboard. I only assume that it is because I should add another action
add_action('admin_footer-post-new.php', 'super_category_toggler');
Copyhowever I’m not sure what is the name of php file in which the Dashboard is located and failed to find it in files. I wonder if it might be mvx_vendor_head or even whole wp.
Thanks in advance for any tips!
-
July 3, 2023 at 8:24 PM #194037NerdySupportExpert MoumitaKeymaster
@srv46126, the team is looking into this.
Kindly provide them some time. -
July 4, 2023 at 3:55 PM #194066MVX Support NinjaKeymaster
Hello @srv46126. We have checked the code shared by you and got to know that using the above code you can only implement your required flow in the admin end. The code will not be effective to implement the flow on vendor end.
However you can implement your required flow for the the vendor using the below hook –
do_action( 'mvx_add_product_form_end' );
Copy -
July 4, 2023 at 7:01 PM #194086srv46126Participant
Hi,
Yes, as I said after new MVX Pro update it stopped working on vendor end. After trying to add your do_action the effect is still the same, so it doesn’t work.
-
July 5, 2023 at 11:58 AM #194099Sangita Support SquadKeymaster
The hook you are using for the flow will only work for admin, the reason is we don’t have any support of this hook for us.
You will need to use our mvx hook that we have shared already, to implement the flow in the vendor dashboard. That is why we have shared our hook, only using this you can implement the flow for vendor dashboard.
But as you are saying that with the earlier version of MultiVendorX Pro the flow was working fine for vendors, it might happen that there was some more code that was added for vendors.
Can you create the modified code on your end? -
July 7, 2023 at 2:49 PM #194174srv46126Participant
In other words according to my previous post – I have changed the code as you have advised me and it did not solve my issue. New code:
function super_category_toggler() { $taxonomies = apply_filters('super_category_toggler',array()); for($x=0;$x<count($taxonomies);$x++) { $taxonomies[$x] = '#'.$taxonomies[$x].'div .selectit input'; } $selector = implode(',',$taxonomies); if($selector == '') $selector = '.selectit input'; echo ' <script> jQuery("'.$selector.'").change(function(){ var $chk = jQuery(this); var ischecked = $chk.is(":checked"); $chk.parent().parent().siblings().children("label").children("input").each(function(){ var b = this.checked; ischecked = ischecked || b; }) checkParentNodes(ischecked, $chk); }); function checkParentNodes(b, $obj) { $prt = findParentObj($obj); if ($prt.length != 0) { $prt[0].checked = b; checkParentNodes(b, $prt); } } function findParentObj($obj) { return $obj.parent().parent().parent().prev().children("input"); } </script> '; } add_action('admin_footer-post.php', 'super_category_toggler'); add_action('admin_footer-post-new.php', 'super_category_toggler'); do_action( 'mvx_add_product_form_end');
CopyI’ve also tried following code, without success aswell:
do_action( 'mvx_add_product_form_end', 'super_category_toggler');
Copydo_action( 'mvx_add_product_form_end.php', 'super_category_toggler');
Copyadd_action( 'mvx_add_product_form_end', 'super_category_toggler');
Copyadd_action( 'mvx_add_product_form_end.php', 'super_category_toggler');
Copy -
July 7, 2023 at 8:46 PM #194185Sangita Support SquadKeymaster
Add the below code in the functions.php file of your current active theme to implement the flow for the vendor dashboard.
//vendor dashboard add_action('mvx_after_add_product_form', 'mvx_category_toggler'); function mvx_category_toggler(){ ?> <script type="text/javascript"> jQuery("input[name='tax_input[product_cat][]']").change(function($){ if (jQuery(this).is(':checked')) { var $chk = jQuery(this); var ischecked = $chk.is(":checked"); var parent = jQuery(this).parent().parent().parent().parent().children("input[name='tax_input[product_cat][]']").filter(':visible:first'); parent.prop('checked', this.checked); //parent parent.parent().parent().parent().parent().children("input[name='tax_input[product_cat][]']").filter(':visible:first').prop('checked', this.checked); } }); </script> <?php }
Copy -
July 10, 2023 at 4:43 PM #194242srv46126Participant
Hello
we can consider problem as solved. Thank your for your assistance.
-
July 10, 2023 at 5:25 PM #194247Sangita Support SquadKeymaster
Thanks for the update. We are happy to help.
Can you please give us 5/5 review here: https://wordpress.org/support/plugin/dc-woocommerce-multi-vendor/reviews/#new-post
This would motivate the team further to do their job more efficiently.
-
-
AuthorPosts
The topic ‘Script issue after new update.’ is closed to new replies.