Category: Woocommerce Hooks

  • Woocommerce Hook Remove Tabs Single Product Page

    Woocommerce Hook Remove Tabs Single Product Page

    Hello, welcome to therichpost.com. In this post, I will tell you Woocommerce Hook Remove Tabs Single Product Page. WordPress is the best cms and Woocommerce is the best Ecommerce plugin. WordPress hooks(add_action, add_filter) give us the power to edit or change the code without interruption into the files and this is the best thing about wordpress. Now I am going to tell you how the hooks work.

    Here is the working code for Woocommerce Hook Remove Tabs Single Product Page and you need to add this into your theme’s functions.php file:

    add_filter( ‘woocommerce_product_tabs’, ‘rich_woo_remove_reviews_tab’, 98 );

    function rich_woo_remove_reviews_tab( $tabs ) {

    unset( $tabs[‘description’] ); // Remove the description tab
    unset( $tabs[‘reviews’] ); // Remove the reviews tab
    unset( $tabs[‘additional_information’] ); // Remove the additional information tab

    return $tabs;

    }

     

    There are so many hooks in wordpress and i will let you know all. Please do comment if you any query related to this post. Thank you. Therichpost.com

  • Woocommerce Category Based Discount Hook

    Woocommerce Category Based Discount Hook

    Hello, welcome to therichpost.com. In this post, I will tell you Woocommerce Category Based Discount Hook. WordPress is the best cms and Woocommerce is the best Ecommerce plugin. WordPress hooks(add_action, add_filter) give us the power to edit or change the code without interruption into the files and this is the best thing about wordpress. Now I am going to tell you how the hooks work.

    I have used category id in woocommerce hook to add discount.

    Here is the working code for Woocommerce Category Based Discount Hook:

    // Add Service Fee to Category
    function woo_add_cart_fee() {
    $category_ID = ’18’;
    global $woocommerce;
    foreach ($woocommerce->cart->cart_contents as $key => $values ) {
    // Get the terms, i.e. category list using the ID of the product
    $terms = get_the_terms( $values[‘product_id’], ‘product_cat’ );
    // Because a product can have multiple categories, we need to iterate through the list of the products category for a match
    foreach ($terms as $term) {
    // 18 is the ID of the category for which we want to add discoun
    if($term->term_id == $category_ID){
    $discount = $woocommerce->cart->subtotal * 0.2;
    $woocommerce->cart->add_fee(‘You have products in Cap category, so 20% discount has been added.’, -$discount);
    }
    }

    }
    }
    add_action( ‘woocommerce_cart_calculate_fees’, ‘woo_add_cart_fee’ );

    There are so many hooks in wordpress and i will let you know all. Please do comment if you any query related to this post. Thank you. Therichpost.com

  • Woocommerce Hook Hide Product Prices For Non Logged In Users

    Woocommerce Hook Hide Product Prices For Non Logged In Users

    Hello, welcome to therichpost.com. In this post, I will tell you Woocommerce Hook Hide Product Prices For Non Logged In Users. WordPress is the best cms and Woocommerce is the best Ecommerce plugin. WordPress hooks(add_action, add_filter) give us the power to edit or change the code without interruption into the files and this is the best thing about wordpress. Now I am going to tell you how the hooks work.

    Here is the working hook for Woocommerce Hook Hide Product Prices For Non Logged In Users and you need to add this into your theme’s functions.php file:

    function hide_product_price( $price ) {
    if(!is_user_logged_in())
    {
    $price = ‘ For pricing, you need to login first’;
    return $price;
    }
    else
    {
    return $price;
    }
    }
    add_filter( ‘woocommerce_get_price_html’, ‘hide_product_price’ );

    There are so many hooks in wordpress and i will let you know all. Please do comment if you any query related to this post. Thank you. Therichpost.com

  • Woocommerce Bulk Quantity Discount Hook

    Woocommerce Bulk Quantity Discount Hook

    Hello, welcome to therichpost.com. In this post, I will tell you Woocommerce Bulk Quantity Discount Hook. WordPress is the best cms and Woocommerce is the best Ecommerce plugin. WordPress hooks(add_action, add_filter) give us the power to edit or change the code without interruption into the files and this is the best thing about wordpress. Now I am going to tell you how the hooks work.

    If user will have 10 or more items in his/her cart then user will get discount.

    Here is the working code for Woocommerce Bulk Quantity Discount Hook:

    /*Bulk Quantity Discounts*/
    add_action(‘woocommerce_cart_calculate_fees’ , ‘add_discount’);

    /**
    * Add custom fee if more than three article
    * @param WC_Cart $cart
    */
    function add_discount( WC_Cart $cart ){
    if( $cart->cart_contents_count < 10 ){
    return;
    }

    // Calculate the amount to reduce
    $discount = $cart->subtotal * 0.2;
    $cart->add_fee( ‘You have more than 10 items in your cart, a 20% discount has been added.’, -$discount);
    }

    There are so many hooks in wordpress and i will let you know all. Please do comment if you any query related to this post. Thank you. Therichpost.com

  • Countries based payments methods with woocommerce add filter

    Countries based payments methods with woocommerce add filter

    Hello, welcome to therichpost.com. In this post, I will tell you How to change Countries based payments methods with woocommerce add filter? WordPress is the best cms and Woocommerce is the best Ecommerce plugin. WordPress hooks(add_action, add_filter) give us the power to edit or change the code without interruption into the files and this is the best thing about wordpress. Now I am going to tell you how the hooks work.

    There are many payments gateways in woocommerce and we can show different payment methods for different countries.

    Here you can check the images with Countries based payments methods:

    Image first:

    Image Second:

    And Now Final, here is the woocommerce hook to change Countries based payments methods with woocommerce add filter and you need to add this hook into your wordpress theme’s functions.php file:

    function payment_gateway_disable_country( $available_gateways ) {
    global $woocommerce;
    if ($woocommerce->customer->get_country() == ‘US’) {
    unset( $available_gateways[‘cod’] );
    }
    else
    {
    unset( $available_gateways[‘paypal’] );
    }
    return $available_gateways;
    }
    add_filter( ‘woocommerce_available_payment_gateways’, ‘payment_gateway_disable_country’ );

    There are so many hooks in wordpress and i will let you know all. Please do comment if you any query related to this post. Thank you. Therichpost.com

  • How to remove product price from single product page with woocommerce hook?

    How to remove product price from single product page with woocommerce hook?

    Hello, welcome to therichpost.com. In this post, I will tell you How to remove product price from single product page with woocommerce hook? WordPress is the best cms and Woocommerce is the best Ecommerce plugin. WordPress hooks(add_action, add_filter) give us the power to edit or change the code without interruption into the files and this is the best thing about wordpress. Now I am going to tell you how the hooks work.

    Here is the working image with removed price:

    And Now Final, here is the woocommerce hook to remove product price from single product page and you need to add this hook into your wordpress theme’s functions.php file:

    remove_action( ‘woocommerce_single_product_summary’, ‘woocommerce_template_single_price’, 10 );

    There are so many hooks in wordpress and i will let you know all. Please do comment if you any query related to this post. Thank you. Therichpost.com

  • How to add request a quote button on product page with woocommerce add action hook?

    How to add request a quote button on product page with woocommerce add action hook?

    Hello, welcome to therichpost.com. In this post, I will tell you How to add request a quote button on product page with woocommerce add action hook? WordPress is the best cms and Woocommerce is the best Ecommerce plugin. WordPress hooks(add_action, add_filter) give us the power to edit or change the code without interruption into the files and this is the best thing about wordpress. Now I am going to tell you how the hooks work.

    Here is the working Woocommerce hook:

    And Now Final, here is the woocommerce add action hook to add request a quote button on product page and you need to add this hook into your wordpress theme’s functions.php file:

    add_action( ‘woocommerce_single_product_summary’, ‘my_extra_button_on_product_page’, 30 );
    function my_extra_button_on_product_page() {
    echo ‘<button type=”submit” class=”button alt”>Request A quote</button>’;
    }

    There are so many hooks in wordpress and i will let you know all. Please do comment if you any query related to this post. Thank you. Therichpost.com

  • How to add product thumbnail to review order table on checkout page with woocommerce add filter hook?

    How to add product thumbnail to review order table on checkout page with woocommerce add filter hook?

    Hello, welcome to therichpost.com. In this post, I will tell you How to add product thumbnail to review order table on checkout page with woocommerce add filter hook? WordPress is the best cms and Woocommerce is the best Ecommerce plugin. WordPress hooks(add_action, add_filter) give us the power to edit or change the code without interruption into the files and this is the best thing about wordpress. Now I am going to tell you how the hooks work. Here is the first image of review order table on checkout page without applying woocommerce hook: Here is the first image of product thumbnail to review order table on checkout page after applying woocommerce hook: And Now Final, here is the woocommerce hook to show product thumbnail to review order table on checkout page and you need to add this hook into your wordpress theme’s functions.php file:

    function isa_woo_cart_attributes($cart_item, $cart_item_key){ 
    global $product; 
    if (is_cart()){ echo "<style>#checkout_thumbnail{display:none;}</style>"; } 
    $item_data = $cart_item_key['data']; 
    $post = get_post($item_data->id); 
    $thumb = get_the_post_thumbnail($item_data->id, array( 32, 50)); 
    echo '<div id="checkout_thumbnail" style="float: left; padding-right: 8px">' . $thumb . '</div> ' . $post->post_title; } add_filter('woocommerce_cart_item_name', isa_woo_cart_attributes, 10, 2);

     

    There are so many hooks in wordpress and i will let you know all. Please do comment if you any query related to this post. Thank you. Therichpost.com

  • How to remove the .00 trailing zero’s from products prices with woocommerce add filter hook?

    How to remove the .00 trailing zero’s from products prices with woocommerce add filter hook?

    Hello, welcome to therichpost.com. In this post, I will tell you How to remove the .00 trailing zero’s from products prices with woocommerce add filter hook? WordPress is the best cms and Woocommerce is the best Ecommerce plugin. WordPress hooks(add_action, add_filter) give us the power to edit or change the code without interruption into the files and this is the best thing about wordpress. Now I am going to tell you how the hooks work.

    Here is the first image of product price without applying woocommerce hook:

    Here is the first image of product price after applying woocommerce hook:

    And Now Final, here is the woocommerce hook to remove the .00 trailing zero’s from products prices and you need to add this hook into your wordpress theme’s functions.php file:

    add_filter( ‘woocommerce_price_trim_zeros’, ‘wc_hide_trailing_zeros’ );
    function wc_hide_trailing_zeros( $trim ) {
    // set to true to hide trailing zeros
    return true;
    }

    There are so many hooks in wordpress and i will let you know all. Please do comment if you any query related to this post. Thank you. Therichpost.com

  • How to show dynamic order totals before place my order button on checkout page with woocommerce add filter hook?

    How to show dynamic order totals before place my order button on checkout page with woocommerce add filter hook?

    Hello, welcome to therichpost.com. In this post, I will tell you How to show dynamic order totals before place my order button on checkout page with woocommerce add filter hook? WordPress is the best cms and Woocommerce is the best Ecommerce plugin. WordPress hooks(add_action, add_filter) give us the power to edit or change the code without interruption into the files and this is the best thing about wordpress. Now I am going to tell you how the hooks work.

    Here is the first image of checkout page without applying woocommerce hook:

    Here is the first image of checkout page after applying woocommerce hook:

    And Now Final, here is the woocommerce hook to show dynamic order totals before place my order button on checkout page and you need to add this hook into your wordpress theme’s functions.php file:

    add_action(‘woocommerce_review_order_before_submit’, ‘GetOrderTotal’);
    function GetOrderTotal($order_id) {
    global $woocommerce;
    echo “<div id=’order_total_text’>Order Total: <strong>$” . $woocommerce->cart->total . ” AUD</strong></div>”;
    }

    There are so many hooks in wordpress and i will let you know all. Please do comment if you any query related to this post. Thank you. Therichpost.com