Custom Add To Cart Button Woocommerce Ajax Code Example


Example: add_to_cart how to call it woocommerce

add_action( 'template_redirect', 'quadlayers_add_to_cart_function' );  function quadlayers_add_to_cart_function () {      $product_id = 1326;      if ( WC()->cart->get_cart_contents_count() == 0 ) {          WC()->cart->add_to_cart( $product_id );      }  }

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable