WooCommerce Change “$0.00” to “Free”

/** * Snippet Name: WooCommerce Change “$0.00” to “Free” * Snippet Author: ecommercehints.com */ add_filter( ‘woocommerce_get_price_html’, ‘ecommercehints_change_zero_price_display’, 10, 2 ); function ecommercehints_change_zero_price_display( $price, $product ) { if (empty($product->get_price()) || $product->get_price() == 0) { // If price is not entered or…Continue reading

Prevent Wholesale Customer to Add Product to the Cart If The Product is Low on Stock

// Prevent wholesale customer to add to cart if the product is low on stock add_filter(‘woocommerce_is_purchasable’, ‘wwpp_disable_cart_lowstock’, 10, 2 ); add_filter(‘woocommerce_variation_is_purchasable’, ‘wwpp_disable_cart_lowstock’, 10, 2 ); function wwpp_disable_cart_lowstock( $purchasable, $product ) { global $wc_wholesale_prices_premium; $user_wholesale_role = $wc_wholesale_prices_premium->wwpp_wholesale_roles->getUserWholesaleRole(); if( !empty( $user_wholesale_role )…Continue reading

Removing Fields from WooCommerce Checkout

function g9_remove_woocommerce_checkout_fields($fields) { // Remove billing fields unset($fields[‘billing’][‘billing_first_name’]); unset($fields[‘billing’][‘billing_last_name’]); unset($fields[‘billing’][‘billing_company’]); unset($fields[‘billing’][‘billing_address_1’]); unset($fields[‘billing’][‘billing_address_2’]); unset($fields[‘billing’][‘billing_city’]); unset($fields[‘billing’][‘billing_postcode’]); unset($fields[‘billing’][‘billing_country’]); unset($fields[‘billing’][‘billing_state’]); unset($fields[‘billing’][‘billing_phone’]); unset($fields[‘billing’][‘billing_email’]); // Remove shipping fields unset($fields[‘shipping’][‘shipping_first_name’]); unset($fields[‘shipping’][‘shipping_last_name’]); unset($fields[‘shipping’][‘shipping_company’]); unset($fields[‘shipping’][‘shipping_address_1’]); unset($fields[‘shipping’][‘shipping_address_2’]); unset($fields[‘shipping’][‘shipping_city’]); unset($fields[‘shipping’][‘shipping_postcode’]); unset($fields[‘shipping’][‘shipping_country’]); unset($fields[‘shipping’][‘shipping_state’]); // Remove order comment fields unset($fields[‘order’][‘order_comments’]); return $fields; }…Continue reading

Limit WooCommerce Order Note Length

function g9_limit_order_note_length($fields) { $fields[‘order’][‘order_comments’][‘maxlength’] = 200; return $fields; } add_filter(‘woocommerce_checkout_fields’, ‘g9_limit_order_note_length’);Continue reading

Allow Shortcodes in Product Excerpts

if (!function_exists(‘woocommerce_template_single_excerpt’)) { function woocommerce_template_single_excerpt($post) { global $post; if ($post->post_excerpt) echo ‘ ‘ . do_shortcode(wpautop(wptexturize($post->post_excerpt))) . ‘ ‘; } }Continue reading

Automatically Add Product to Cart on Visit

function g9_add_product_to_cart() { if (!is_admin()) { $product_id = 64; //replace with your own product id $found = false; //check if product already in cart if (sizeof(WC()->cart->get_cart()) > 0) { foreach (WC()->cart->get_cart() as $cart_item_key => $values) { $_product = $values[‘data’]; if…Continue reading

Change Add to Cart text on Single & Archive Product Page

// Change add to cart text on single product page function g9_woocommerce_add_to_cart_button_text_single() { return __(‘Add to Cart Button Text’, ‘woocommerce’); } add_filter(‘woocommerce_product_single_add_to_cart_text’, ‘g9_woocommerce_add_to_cart_button_text_single’); // Change add to cart text on product archives page function g9_woocommerce_add_to_cart_button_text_archives() { return __(‘Add to Cart…Continue reading