Apply Additional Discount after coupon

Put this code in your current theme function.php file. Set how many discount as per your require. function add_extra_discount( $cart ) { $discount = $cart->subtotal * 0.3; $cart->add_fee( __( ‘Extra Discount’, ‘twentyseventeen’ ) , -$discount ); } add_action( ‘woocommerce_cart_calculate_fees’, ‘add_extra_discount’ );

Get the category ID in checkout page woocomerce

Getting the ids of the items in your cart can be done somewhat like this: global $woocommerce; $cart = $woocommerce->cart->get_cart(); $cart_items_ids = array(); foreach ( $cart as $item_key => $item_value ) { $cart_items_ids[] = $item_value[ ‘data’ ]->id; } OR Plese check below Snippet: Check if Product Category is in the Cart – WooCommerce add_action(‘woocommerce_before_cart’, ‘xyz_check_category_in_cart’); … Read more

Woocommerce exclude specific categories products from related products

add_action( ‘wp’, ‘vn_remove_related_products’ ); function vn_remove_related_products() { if ( is_product() && has_term( array(‘workshops’, ‘events’), ‘product_cat’ ) ) { remove_action( ‘woocommerce_after_single_product_summary’, ‘woocommerce_output_related_products’, 20 ); } } Function has_term() can pass first parameter as array with terms.

if statement for search results

Within the loop the best way to check if the result is a product would be to check the value of get_post_type(): if ( get_post_type() === ‘product’ ) { } As you say, is_woocommerce(), is_product() and is_search() are for checking which type of page is being viewed regardless of the current item in the loop.

Fatal Error in WordPress WooCommerce theme “Call to undefined function wc_get_theme_slug_for_templates()”

Ok, the error is telling you this: The error comes from this theme file: \themes\vw-ecommerce-shop\woocommerce\global\wrapper-end.php Line: 23. In that file on line 23 the following function is called wc_get_theme_slug_for_templates() but at that point it’s not (yet) available. The function should be available though, because it’s a valid Woocommerce function, see here. Can you update your … Read more

Hiding products with a specific tag from WooCommerce main shop page

You can paste the following snippet in your child theme’s functions.php function exclude_specific_tag( $q ) { if (is_shop()){ $tax_query = (array) $q->get( ‘tax_query’ ); $tax_query[] = array( ‘taxonomy’ => ‘product_tag’, ‘field’ => ‘slug’, ‘terms’ => array( ‘pré-commande’ ), // write the tag name to remove in between the ” ‘operator’ => ‘NOT IN’ ); $q->set( … Read more

Send a value to woocommerce with a button type submit

At the select tag you have 2 name attribute <select type=”number” step=”any” name=”actions” id=”actions-select” name=”wpneo_donate_amount_field” class=”input-text amount wpneo_donate_amount_field text”> Then, when you submit, it only collect the first defined name. (name=”actions”). You have to delete this attribute. and using name=”wpneo_donate_amount_field” only. It should like <select type=”number” step=”any” id=”actions-select” name=”wpneo_donate_amount_field” class=”input-text amount wpneo_donate_amount_field text”>

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)