• Skip to main content
  • Skip to primary sidebar

WordPress, Genesis Framework and Storefront customization tutorials

  • Free
  • Premium
  • Membership
    • Login
  • Design
  • Blog
  • About
  • Contact
Home » WooCommerce

WooCommerce

Remove tax included price for wholesalers in WooCommerce

2020-10-29 by Gabor Leave a Comment

Filed Under: Free Tagged With: Storefront, WooCommerce

Hook Data Layer with variables for Google Tag Manager in WooCommerce

2020-06-11 by Gabor 1 Comment

Filed Under: Free Tagged With: tag manager, WooCommerce

[Upsell] How to create a modal when clicking the “Add to cart” button in WooCommerce

2020-04-20 by Gabor Leave a Comment

Would You like to create an upsell popup for WooCoomerce, when the customer clicks to the "Add to cart" button? You don't need to buy any kind of plugins to do it. In this post I'm going to show you how to code the functionality to boost your sales in WooCommerce.

You can place and style any kind of upsell content in this popup:



To view the full content, please sign up for the membership.

If You are already a member, please log in below:

 
 
Forgot Password

Filed Under: Premium Tagged With: upsell, WooCommerce

How to select “Add to cart” button with jQuery

2020-04-19 by Gabor Leave a Comment

jQuery(document).ready(function() {
jQuery(‘body’).on(‘click’, ‘.add_to_cart_button’, function() {
jQuery(this)
alert(“HELLO”);
});
});

Filed Under: Free Tagged With: jQuery, WooCommerce

How to Change “Place Order” text in WooCommerce Checkout

2020-04-19 by Gabor Leave a Comment

// =============================================================
// CHANGE PLACE ORDER TEXT
// =============================================================
add_filter('woocommerce_order_button_html', 'change_place_order_button');

function change_place_order_button($button_html){
    $button_html = str_replace('Place order', 'Order Now', $button_html);
    return $button_html;
}

Filed Under: Free Tagged With: WooCommerce

Excluded TAX for specific user role in WooCommerce

2020-04-04 by Gabor Leave a Comment

function tax_excluded_price_per_user_role( $value ) {
    if ( current_user_can( 'wholesale_customer' ) ) {
        return 'excl';
    }
    return $value;
}
add_filter( 'pre_option_woocommerce_tax_display_shop', 'tax_excluded_price_per_user_role' );
add_filter( 'pre_option_woocommerce_tax_display_cart', 'tax_excluded_price_per_user_role' );

Filed Under: Free Tagged With: WooCommerce

Show the price in different currency on product archive page in WooCommerce

2020-04-03 by Gabor 1 Comment

// =========================================================================
// SHOW PRICE IN EURO
// ========================================================================= 
function show_price_in_euro(){
    global $product;
    
     if( $product->has_child() ) {
        $product->get_id();
        $var_price_huf = $product->get_variation_price( 'min', true );
        $exchange_rate = 360;
        $price_eur = $var_price_huf / $exchange_rate;
        echo '<span class="price euro"><span class="woocommerce-Price-amount amount eur">'.round($price_eur, 1).' €</span></span>';
    }
    else{
        $product->get_id();
        $price_huf = $product->get_price(); 
        $exchange_rate = 360;
        $price_eur = $price_huf / $exchange_rate;
        echo '<span class="price euro"><span class="woocommerce-Price-amount amount eur">'.round($price_eur, 1).' €</span></span>';
    }
}
add_action('woocommerce_after_shop_loop_item', 'show_price_in_euro',-1);

Filed Under: Free Tagged With: WooCommerce

Specific Shipping Method Based on Minimum Order Amount in WooCommerce

2020-04-03 by Gabor Leave a Comment

// =========================================================================
// MINIMUM ORDER AMOUNT FOR SPECIFIC SHIPPING METHOD
// =========================================================================
function minimum_order_amount_for_shipping( $rates, $package ) {
   $threshold = 100;
   if ( WC()->cart->subtotal < $threshold ) {
         unset( $rates['flat_rate:2'] );
   } 
   return $rates;
}
add_filter( 'woocommerce_package_rates', 'minimum_order_amount_for_shipping', 10, 2 );

Filed Under: Free Tagged With: WooCommerce

How to show the percentage value of your discounts in WooCommerce

2020-04-02 by Gabor Leave a Comment

// =========================================================================
// SHOW THE PERCENTAGE VALUE OF DISCOUNT PRODUCTS
// =========================================================================
function woocommerce_custom_sales_price( $price, $regular_price, $sale_price ) {
    global $product;
    if( $product->has_child() ) {
        $var_regular_price = $product->get_variation_regular_price( 'min', true );
        $var_sale_price = $product->get_variation_price( 'min', true );
        
        $percentage = round( ( $var_regular_price - $var_sale_price ) / $var_regular_price * 100 ).'%';
        $percentage_txt = ' ' . __('<span class="sale-percentage"> -', 'woocommerce' , '</span>') . $percentage;
        $price = '<del>' . ( is_numeric( $regular_price ) ? wc_price( $regular_price ) : $regular_price ) . '</del> <ins>' . ( is_numeric( $sale_price ) ? wc_price( $sale_price ) . $percentage_txt : $sale_price . $percentage_txt ) . '</ins>';
        return $price;
    }
    else{
        $percentage = round( ( $regular_price - $sale_price ) / $regular_price * 100 ).'%';
        $percentage_txt = ' ' . __('<span class="sale-percentage"> -', 'woocommerce' , '</span>') . $percentage;
        $price = '<del>' . ( is_numeric( $regular_price ) ? wc_price( $regular_price ) : $regular_price ) . '</del> <ins>' . ( is_numeric( $sale_price ) ? wc_price( $sale_price ) . $percentage_txt : $sale_price . $percentage_txt ) . '</ins>';
        return $price;
    }
}
add_filter( 'woocommerce_format_sale_price', 'woocommerce_custom_sales_price', 10, 3 );

Filed Under: Free Tagged With: WooCommerce

Add extra fee based on shipping method in WooCommerce

2020-04-02 by Gabor Leave a Comment

// =========================================================================
// ADD EXTRA FEE BASED ON SHIPPING METHOD
// =========================================================================
add_action( 'woocommerce_cart_calculate_fees','wc_add_surcharge' ); 
function wc_add_surcharge() { 
    
    global $woocommerce; 

    if ( is_admin() && ! defined( 'DOING_AJAX' ) ) 
        
    return;
    
    $chosen_methods = WC()->session->get( 'chosen_shipping_methods' );
          
    $chosen_shipping = $chosen_methods[0];
    
    $fee = 10;

    if ( $chosen_shipping == 'flat_rate:2' ) {
        $woocommerce->cart->add_fee( 'Extra fee: ', $fee, true, 'standard' );  
    }
}

Filed Under: Free Tagged With: WooCommerce

How to add Custom Terms and Conditions Checkbox to WooCommerce Checkout

2020-04-02 by Gabor Leave a Comment

// =========================================================================
// CUSTOM TERMS AND CONDITIONS CHECKBOX IN WOO
// =========================================================================
function add_checkbox_to_woocommerce_checkout() {
    ?>
    <p id="wpgdprc_field" class="form-row wpgdprc-checkbox validate-required">
       <span class="woocommerce-input-wrapper">
        <label class="checkbox">
            <input id="wpgdprc" type="checkbox" value="1" class="input-checkbox" name="wpgdprc" > 
            <span class="gdpr-privacy">I've read and accept the  <a target="_blank" href="/terms-and-conditions/">Terms and Conditions</a></span>
            <abbr class="wpgdprc-required required" title="This field is required">*</abbr>
        </label>
        </span>
      
    </p>
    <?php
}
add_action('woocommerce_checkout_after_terms_and_conditions', 'add_checkbox_to_woocommerce_checkout' );

Filed Under: Free Tagged With: WooCommerce

Change “Related products” text in WooCommerce

2020-02-25 by Gabor Leave a Comment

// =========================================================================
// CHANGE RELATED PRODUCTS TEXT TO YOU MAY ALSO LIKE TEXT
// =========================================================================  
function change_you_may_also_like( $translated ) {
   $translated = str_replace( 'Related products', 'You may also like...', $translated );
   return $translated;
}
add_filter( 'gettext', 'change_you_may_also_like' );

Filed Under: Free Tagged With: WooCommerce

How to change “On Sale” text in WooCommerce

2020-02-25 by Gabor Leave a Comment

// =========================================================================
// CHANGE ON SALE TEXT
// =========================================================================
function woocommerce_custom_sale_text($text, $post, $_product){
    return '<span class="onsale">Special offer</span>';
}
add_filter('woocommerce_sale_flash', 'woocommerce_custom_sale_text', 10, 3);

Filed Under: Free Tagged With: WooCommerce

How to change Additional information text based on product ID in WooCommerce

2020-02-21 by Gabor 1 Comment

// =========================================================================
// CHANGE ADDITIONAL INFORMATION TEXT
// =========================================================================
/* @return string Modified value for product's "Additional information" text. */
function wpdd_change_additional_information_heading() {
    global $product;
    if( $product->id == 2028 ){
	   return __( 'Further information', 'mytextdomain' );
    }elseif($product->id == 2027){
	   return __( 'En savoir plus', 'mytextdomain' );
    }else{
        return __( 'További információk', 'woocommerce' );
    }
}
add_filter( 'woocommerce_product_additional_information_heading', 'wpdd_change_additional_information_heading' );

Filed Under: Free Tagged With: WooCommerce

Change “Add to cart” button text on specific pages in Woo

2020-02-18 by Gabor 1 Comment

// =========================================================================
// CHANGE ADD TO CART BUTTON TEXT ON SPECIFIC PAGES
// =========================================================================
function translate_add_to_cart() {
    global $product;
    if( $product->id == 2028 ){
        return __( 'Add to basket', 'woocommerce' );
    } elseif($product->id == 2027){
        return __( 'Buy now', 'woocommerce' );
        }
    else{
        return __( 'Add to cart', 'woocommerce' );
    }
}
add_filter( 'woocommerce_product_single_add_to_cart_text', 'translate_add_to_cart', 10, 3 );

Filed Under: Free Tagged With: WooCommerce

How to list WooCommerce product categories

2020-01-22 by Gabor Leave a Comment

// =========================================================================
// DISPLAY PRODUCT CATEGORIES
// =========================================================================
function woocommerce_product_category( $args = array() ) {
    $woocommerce_category_id = get_queried_object_id();
  $args = array(
      'parent' => $woocommerce_category_id
  );
  $terms = get_terms( 'product_cat', $args );
  if ( $terms ) {
      echo '<ul id="myFilter" class="woocommerce-categories">';
      foreach ( $terms as $term ) {
          echo '<li class="woocommerce-product-category-page">';
              echo '<a href="' .  esc_url( get_term_link( $term ) ) . '" class="btn-filter ' . $term->slug . '">';
                echo $term->name;
              echo '</a>';
          echo '</li>';
      }
      echo '</ul>';
  }
}
add_action( 'woocommerce_archive_description', 'woocommerce_product_category', 10 );

Filed Under: Free Tagged With: WooCommerce

How to move additional information after add to cart button

2019-07-13 by Gabor Leave a Comment

// =========================================================================
// REMOVE ADDITIONAL INFORMATION TAB
// =========================================================================
add_filter( 'woocommerce_product_tabs', 'remove_additional_information_tab', 100, 1 );
function remove_additional_information_tab( $tabs ) {
    unset($tabs['additional_information']);

    return $tabs;
}

// =========================================================================
// ADD ADDITIONAL INFORMATION AFTER ADD TO CART
// =========================================================================
add_action( 'woocommerce_single_product_summary', 'additional_info_under_add_to_cart', 35 );
function additional_info_under_add_to_cart() {
    global $product;

    if ( $product && ( $product->has_attributes() || apply_filters( 'wc_product_enable_dimensions_display', $product->has_weight() || $product->has_dimensions() ) ) ) {
        wc_display_product_attributes( $product );
    }
}

Filed Under: Free Tagged With: WooCommerce

How to show custom message based on shipping class on single product page

2019-07-13 by Gabor Leave a Comment

// =========================================================================
// Custom Text on Product Page based on Shipping Class 
// =========================================================================
function display_shipping_class_on_product_page() {
    $product = wc_get_product();

    $shipping_class = $product->get_shipping_class();

    switch ( $shipping_class ) {
        case 'your_shipping_class_1':
            echo '';
            break;
        case 'your_shipping_class_2':
            echo '';
            break;
    }
}
add_action( 'woocommerce_single_product_summary', 'display_shipping_class_on_product_page', 10 );

Filed Under: Free Tagged With: WooCommerce

Disable payment method for specific country in WooCommerce

2019-04-04 by Gabor Leave a Comment

To view the full content, please sign up for the membership.

If You are already a member, please log in below:

Filed Under: Premium Tagged With: WooCommerce

Add fee to specific payment gateway only for physical products

2019-04-01 by Gabor Leave a Comment

To view the full content, please sign up for the membership.

If You are already a member, please log in below:

Filed Under: Premium Tagged With: WooCommerce

  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Go to page 4
  • Go to Next Page »

Primary Sidebar

  • Facebook
  • GitHub
  • Instagram
  • LinkedIn
  • Twitter
  • YouTube
WP Rocket - WordPress Caching Plugin
UpdraftPlus Premium

Disclosure: Some of the links in this site are affiliate links. I will be paid a commission if you use this link to make a purchase.

  • Privacy Policy
  • Terms of Service
  • Flames Design
© 2021 WP Flames - All Right Reserved