Banner Logo

Be a part of the family: Connect, Receive Support,
Contribute, and Reap Abundant Rewards

Script issue after new update.

MultivendorX Pro

Resolved
Viewing 10 reply threads
  • Author
    Posts
    • #193925
      srv46126
      Participant

      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
    • #193961

      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.

    • #194025
      srv46126
      Participant

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

      however 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!

    • #194037

      @srv46126, the team is looking into this.
      Kindly provide them some time.

    • #194066

      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
    • #194086
      srv46126
      Participant

      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.

    • #194099

      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?

    • #194174
      srv46126
      Participant

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

      I’ve also tried following code, without success aswell:

      
      do_action( 'mvx_add_product_form_end', 'super_category_toggler');
      
      Copy
      
      do_action( 'mvx_add_product_form_end.php', 'super_category_toggler');
      
      Copy
      
      add_action( 'mvx_add_product_form_end', 'super_category_toggler');
      
      Copy
      
      add_action( 'mvx_add_product_form_end.php', 'super_category_toggler');
      
      Copy
    • #194185

      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
    • #194242
      srv46126
      Participant

      Hello

      we can consider problem as solved. Thank your for your assistance.

    • #194247

      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.

Viewing 10 reply threads

The topic ‘Script issue after new update.’ is closed to new replies.