WooCommerce: Webhook disabled on its own

If you don’t want to fix this every time WooCommerce updates, just create a filter in your child-theme: function overrule_webhook_disable_limit( $number ) { return 999999999999; //very high number hopefully you’ll never reach. } add_filter( ‘woocommerce_max_webhook_delivery_failures’, ‘overrule_webhook_disable_limit’ );

how to use wc_create_order with subscription product

Here’s my code for creating a subscription — it took a lot of trial and error to figure it all out. Best of luck! function create_test_sub() { $email=”[email protected]”; $start_date=”2015-01-01 00:00:00″; $address = array( ‘first_name’ => ‘Jeremy’, ‘last_name’ => ‘Test’, ‘company’ => ”, ’email’ => $email, ‘phone’ => ‘777-777-777-777’, ‘address_1′ => ’31 Main Street’, ‘address_2’ => … Read more

Display single product attribute value on Shop page (Woocommerce)

Just use global $product then use get_attribute() method of that product object, like below- $size = $product->get_attribute( ‘pa_size’ ); And you can also get that by below code- global $product; $size = array_shift( wc_get_product_terms( $product->id, ‘pa_size’, array( ‘fields’ => ‘names’ ) ) ); Rememeber you need to use must the global $product.

How to check if is in cart page? [closed]

I’m not sure where are you hooking your function to, but you might be doing it too early. Hook to template_redirect, and then redirect the user: add_action(‘template_redirect’,’redirect_visitor’); function redirect_visitor(){ if ( is_page( ‘cart’ ) || is_cart() ) { wp_safe_redirect(site_url()); exit(); // Don’t forget this one } }

Are there any hook or filter when refund is done through admin -woocommerce

Although this answer is little late but anyone else may get benefit from it. The woocommerce_order_refunded hook is called when an order is refunded. Use the following example: // add the action add_action( ‘woocommerce_order_refunded’, ‘action_woocommerce_order_refunded’, 10, 2 ); // Do the magic function action_woocommerce_order_refunded( $order_id, $refund_id ) { // Your code here }

How to add a new endpoint in woocommerce

seems woocommerce doesn’t have any filters when registering their endpoints, https://github.com/woothemes/woocommerce/blob/master/includes/class-wc-query.php#L84 so you need to add your new endpoint on init hooks, just like this add_action( ‘init’, ‘add_endpoint’ ); function add_endpoint(){ add_rewrite_endpoint( ‘license’, EP_ROOT | EP_PAGES ); } then you have to do some filtering on wc_get_template to call your files when the request match … Read more

Woocommerce show cross sells on singe product page [closed]

add_action(‘woocommerce_after_single_product_summary’, ‘show_cross_sell_in_single_product’, 30); function show_cross_sell_in_single_product(){ $crosssells = get_post_meta( get_the_ID(), ‘_crosssell_ids’,true); if(empty($crosssells)){ return; } $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => -1, ‘post__in’ => $crosssells ); $products = new WP_Query( $args ); if( $products->have_posts() ) : echo ‘<div class=”cross-sells”><h2>Cross-Sells Products</h2>’; woocommerce_product_loop_start(); while ( $products->have_posts() ) : $products->the_post(); wc_get_template_part( ‘content’, ‘product’ ); endwhile; // end of … Read more

Woocommerce: How to remove page-title at the home/shop page but not category pages

you can overwrite woocommerce template of “archive-product.php” into your current theme and replace with this code. <?php if ( apply_filters( ‘woocommerce_show_page_title’, true ) ) : ?> <?php if(!is_shop()) { ?> <h1 class=”page-title”><?php woocommerce_page_title(); ?></h1> <?php } ?> <?php endif; ?> For reference conditional tag of woocommerce OR <?php if ( apply_filters( ‘woocommerce_show_page_title’, true ) ) … Read more