Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • I solved it by pasting this code into child theme’s functions.php file. It sets the shipping fees for all shipping methods to 0.

    function filter_woocommerce_package_rates( $rates, $package ) {
        // Cart total amount (integer)
        $cart_total = WC()->cart->cart_contents_total;
    
        // Greater than or equal to
        if ( $cart_total >= 59.99 ) {
            foreach ( $rates as $rate_key => $rate ) {
                // For "free shipping" method (enabled), remove it
                if ( $rate->method_id == 'free_shipping' ) {
                    unset( $rates[$rate_key] );
                // For other shipping methods
                } else {
                    // Append rate label titles (free)
                    $rates[$rate_key]->label .= ' ' . __( '(free)', 'woocommerce' );
    
                    // Set rate cost
                    $rates[$rate_key]->cost = 0;
    
                    // Set taxes rate cost (if enabled)
                    $taxes = array();
    
                    foreach ( $rates[$rate_key]->taxes as $key => $tax ) {
                        if ( $rates[$rate_key]->taxes[$key] > 0 ) {
                            $taxes[$key] = 0;
                        }
                    }
    
                    $rates[$rate_key]->taxes = $taxes;
                }
            }
        }
    
        return $rates;
    }
    add_filter( 'woocommerce_package_rates','filter_woocommerce_package_rates', 10, 2 );
    Thread Starter mattq321

    (@mattq321)

    It’s essential for me to show the original price in the checkout and then show the discount like it was a coupon discount. Example checkout:

    Price: $1000
    Discount: $500 (or 50%)
    Total: $500

    So I’ll stick to cart adjustment discount rule. Now if I could display both discounted and original price on product/shop/archive pages to each customer, it would be great. Is there a shortcode or anything that would allow me to display the discounted / default price in the shop / product / archive page despite using cart adjustment coupon?

    • This reply was modified 2 years, 6 months ago by mattq321.
Viewing 2 replies - 1 through 2 (of 2 total)