Woocommerce changing add to cart button text as icon [closed]

Default “Add to Cart” template of WooCommerce at “templates/loop/add-to-cart.php” uses function “esc_html()” which escapes HTML blocks in return value. The code you have added is correct. You just need to remove “esc_html()” function from “templates/loop/add-to-cart.php“. // Default Template Code echo apply_filters( ‘woocommerce_loop_add_to_cart_link’, sprintf( ‘<a rel=”nofollow” href=”https://wordpress.stackexchange.com/questions/304517/%s” data-quantity=”https://wordpress.stackexchange.com/questions/304517/%s” data-product_id=”https://wordpress.stackexchange.com/questions/304517/%s” data-product_sku=”https://wordpress.stackexchange.com/questions/304517/%s” class=”https://wordpress.stackexchange.com/questions/304517/%s”>%s</a>’, esc_url( $product->add_to_cart_url() ), esc_attr( isset( … Read more

Woocommerce change price in cart when discounted

You can use this filter in your theme or plugin to filter the product prices: function filter_woocommerce_price( $price, $product ) { // 1. Set your $price_percent variable // 2. Subtract the price_percent from the price $price – $price_percent // 3. Set the new $price return $price; } add_filter( ‘woocommerce_product_get_regular_price’, ‘filter_woocommerce_price’, 10, 2 ); By the … Read more

WooCommerce – Split Multiple Items into Individual Line Items

So I ended up combining a few answer out there and split out orders when adding to the cart, and also when updating the cart. The below works, though it’s purely a front end customization. Hope this helps someone else! function bbloomer_split_product_individual_cart_items( $cart_item_data, $product_id ){ $unique_cart_item_key = uniqid(); $cart_item_data[‘unique_key’] = $unique_cart_item_key; return $cart_item_data; } add_filter( … Read more

is_shop doesn’t work for woocommerce [closed]

is_shop() is returning false because the WordPress query isn’t set up yet when functions.php is run. If you attach it to a hook, like wp_loaded, it should work. add_action( ‘wp_loaded’, ‘remove_main_content’ ); function remove_main_content() { if( is_shop() ) { remove_action(‘woocommerce_before_main_content’, ‘woocommerce_breadcrumb’, 20 ); } }

How can I remove a WooCommerce Product Tab’s sub section in wp-admin?

To change this “sub navigation” you could use the WooCommerce filter “woocommerce_get_sections_products“. The following example code will remove the sub navigation point “inventory”: function change_navi_function($sections) { // remove sub navigation point “inventory” unset($sections[‘inventory’]); return $sections; } add_filter(‘woocommerce_get_sections_products’, ‘change_navi_function’); What you have to do now is either to hook your “change_navi_function” function after the function from … Read more

Woocommerce – Display stock quantity per variation

Displaying stock quantity per product variant is default WooCommerce behavior. For best results, when you develop own theme, use default storefront/woocommerce HTML structure and JS files then style it using CSS styles. To test stock quantity per product variant is displaying correctly I installed clean WordPress 4.9.6 and WooCommerce 3.4.3 and followed Variable product page … Read more

Get woocommerce coupon code

You could use the woocommerce_applied_coupon hook. You find the “implementation” in the class WC_Cart ( method apply_coupon) Usage example: function my_little_coupon_func($coupon_code) { echo “coupon is correct: “. $coupon_code; // now send your email } add_action(‘woocommerce_applied_coupon’, ‘my_little_coupon_func’);

How disable some product features on woocomerce?

Just add below function in your function file /*For remove tab from product tab*/ function remove_linked_products($tabs){ unset($tabs[‘inventory’]); unset($tabs[‘shipping’]); return($tabs); } add_filter(‘woocommerce_product_data_tabs’, ‘remove_linked_products’, 10, 1); /*Remove Virtual and Downloadeble checkbox*/ function remove_product_type_options( $options ) { unset( $options[‘virtual’] ); unset( $options[‘downloadable’] ); return $options; } add_filter( ‘product_type_options’, ‘remove_product_type_options’ );