fbpx

Double add to cart button

WCMp Vendor Vacation

Double add to cart button Resolved

Viewing 5 reply threads
  • Author
    Posts
    • #110999
      inkanov
      Participant

      Hi,

      I’m getting the same error as this ticket. Can you please share the resolution

      https://wc-marketplace.com/support-forum/topic/double-add-to-cart-button-2/

      I cant replicate this on Live site, but its there on localhost. Just as I deactivated the WCMp Vendor Vacation plugin, this double cart went away and it came back when I reactivated it.

    • #111018

      Hi,
      try below code
      Please add this custom css in your site to fix this –

      .product_meta + .variations_form.cart {
          display: none;
      }
      Copy

      Regards,

    • #111075
      inkanov
      Participant
      This reply has been marked as private.
    • #111094

      Hi,
      kindly use this code and test your site.
      //Please add this code in the function.php of the current active theme :

      add_action('init', 'wcmp_vacation_add_to_cart_button');
      function wcmp_vacation_add_to_cart_button(){
           global $WCMP_Vendor_Vacation;
          remove_action('woocommerce_single_product_summary', array($WCMP_Vendor_Vacation->frontend, 'wcmp_single_product_summary'), 29);
          add_action('woocommerce_single_product_summary', 'wcmp_single_product_summary', 29);
      }
      function wcmp_single_product_summary() {
          global $product, $WCMP_Vendor_Vacation;
          $vendor_product = get_wcmp_product_vendors($product->get_id());
          if ($vendor_product) {
              $vendor_vacation_set_up = get_user_meta($vendor_product->id, '_vacation_include_dates', true);
      
              $holidays = isset($vendor_vacation_set_up['include_dates_array']) ? $vendor_vacation_set_up['include_dates_array'] : false;
              $enable_store_time = isset($vendor_vacation_set_up['is_enable_store_time']) ? $vendor_vacation_set_up['is_enable_store_time'] : false;
      
              $today = date('j/n/Y');
      
              $today_is_avoided = false;
      
              if (is_array($holidays) && count($holidays) > 0 && isset($vendor_vacation_set_up['avoid_purchase'])) {
                  if (in_array($today, $holidays)) {
                      remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
                      add_action('woocommerce_single_product_summary', array($WCMP_Vendor_Vacation->frontend, 'wcmp_vacation_avoid_add_to_cart_msg'), 31);
                      $today_is_avoided = true;
                  }
              }
      
              if (!$today_is_avoided) {
                  date_default_timezone_set(get_vendor_timezone_string($vendor_product->id));
                  $shop_open = is_vendor_shop_open($vendor_product->id, $today);
                  if ($shop_open == 'open' || $shop_open == 'close') {
                      if($shop_open == 'open') {
                          add_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
                      } else {
                          remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
                          echo $vendor_vacation_set_up['shop_closed_text'];
                      }
                  } 
              }
          }
      }
      Copy

      You can also override the function from your active theme/function.php

      Regards,

    • #111131
      inkanov
      Participant

      It works, awesome

    • #111233

      Thank you for the update. We are closing the ticket now. In case any issue arises kindly raise a new ticket.

Viewing 5 reply threads

The topic ‘Double add to cart button’ is closed to new replies.

Buy all Marketplace addons together, check out our Bundle

Buy at Slashed Price