How can I define a custom template for woocommerce [products] shortcode? [closed]

Open your theme’s function.php and add following add_action( ‘woocommerce_shortcode_before_products_loop’, ‘roka_before_products_shortcode_loop’, 1, 10 ); add_action( ‘woocommerce_shortcode_after_products_loop’, ‘roka_after_products_shortcode_loop’, 0, 10 ); function roka_before_products_shortcode_loop( $atts ) { $GLOBALS[ ‘roka_woocommerce_loop_template’ ] = ( isset( $atts[ ‘class’ ] ) ? $atts[ ‘class’ ] : ” ); } function roka_after_products_shortcode_loop( $atts ) { $GLOBALS[ ‘roka_woocommerce_loop_template’ ] = ”; } Then override … Read more

How to change or add Woocommerce thank you page URL key content?

you can edit the return url woocommerce provides to gateways by using the filter woocommerce_get_return_url some gateway plugins use a different method to get return url by invoking $order->get_checkout_order_received_url() ; which applies the filter woocommerce_get_checkout_order_received_url an example would be like : add_filter(‘woocommerce_get_return_url’,’override_return_url’,10,2); function override_return_url($return_url,$order){ //create empty array to store url parameters in $sku_list = array(); … Read more

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 } }