CF7 Ajax isn’t working when called inside WooCommerce “woocommerce_before_add_to_cart_button” hook [closed]

I am not sure when the woocommerce_before_add_to_cart_button action fires in the request sequence, but it could be worth adding the following code to your functions.php to see if it loads the CF7 js script files, add_action(‘wp_enqueue_scripts’, ‘pre_register_cf7_files’); function pre_register_cf7_files(){ wp_register_style(‘contact-form-7’, wpcf7_plugin_url( ‘includes/css/styles.css’ ), array(), WPCF7_VERSION, ‘all’ ); wp_register_script( ‘contact-form-7’, wpcf7_plugin_url( ‘includes/js/scripts.js’ ), array( ‘jquery’ ), … Read more

Force meta data on specific product type

You can try the wp_head hook: add_action( ‘wp_head’, ‘check_for_enviso_group_ticket’ ); function check_for_enviso_group_ticket() { if ( is_product() && ( ‘enviso_group_ticket’ == get_the_terms( get_the_ID(), ‘product_type’ )[0]->slug ) ) { echo ‘<meta name=”robots” content=”noindex,nofollow”/>’, PHP_EOL; } } or to not break your site in case the WooCommerce is disabled and the is_product() function isn’t defined: add_action( ‘wp_head’, ‘check_for_enviso_group_ticket’ … Read more

Wooocommerce disable check_cart_item_stock if cart item has specific meta

Finally, I did it like this: function bo_disable_stock_check(){ if(bo_cart_contain_birthlist()){ remove_action(‘woocommerce_check_cart_items’, [WC()->cart, ‘check_cart_items’], 1); add_filter(“woocommerce_product_is_in_stock”, “__return_true”); add_filter(“woocommerce_cart_item_required_stock_is_not_enough”, “__return_false”); } } add_action(‘wp’,’bo_disable_stock_check’); But maybe there are more specific hooks to call than “wp”.

Woocommerce – Change the template?

The dropdown box that you are talking about is for custom WordPress template that WordPress supports by default. In order to override woocomerce template e.g. single-product.php what you have to do is to create a folder with name woocommerce inside your theme folder e.g. /wp-content/themes/{your_theme_name}/woocommerce/ and copy the file from /wp-content/plugins/woocommerce/templates/single-product.php into your theme’s woocommerce … Read more

Adding author option to [products] woocommerce shortcode

Try this: function htdat_shortcode_atts_products( $out, $pairs, $atts, $shortcode ) { if ( isset ( $atts[‘author’] ) ) $out[‘author’] = $atts[‘author’]; return $out; } add_filter(‘shortcode_atts_products’, ‘htdat_shortcode_atts_products’, 10, 4); function htdat_woocommerce_shortcode_products_query( $query_args, $attributes ) { if ( isset( $attributes[‘author’] ) ) $query_args[‘author’] = $attributes[‘author’]; return $query_args; } add_filter( ‘woocommerce_shortcode_products_query’, ‘htdat_woocommerce_shortcode_products_query’, 10, 2 );

How to add order status class to the body tag?

This does the trick add_filter( ‘body_class’, ‘order_class’); function order_class( $orderclasses ) { $user_id = get_current_user_id(); // The current user ID // Get the WC_Customer instance Object for the current user $customer = new WC_Customer( $user_id ); // Get the last WC_Order Object instance from current customer $last_order = $customer->get_last_order(); $order_id = $last_order->get_id(); // Get the … Read more

Send email notifications to a defined email address depending if a product in order has a specific TAG [closed]

To check product has TAG or not you have to fetch product from order and search in them. //Custom NEW ORDER Email address depending on Product Tag add_filter( ‘woocommerce_email_recipient_new_order’, ‘new_order_conditional_email_recipient’, 10, 2 ); function new_order_conditional_email_recipient( $recipient, $order ) { if ( ! is_a( $order, ‘WC_Order’ ) ) return $recipient; // (Optional) // Get the order … Read more