Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter Hassan Yousuf

    (@hassanyousufx)

    Any updates?

    Plugin Author Subrata Mal

    (@subratamal)

    @hassanyousufx Please use the attached code in the theme functions.php file.

    add_filter('process_woo_wallet_general_cashback', 'process_woo_wallet_general_cashback_callback', 10, 2);
    if(!function_exists('process_woo_wallet_general_cashback_callback')){
        /**
         * Disable cashback if coupon used.
         * @param type $process
         * @param WC_Order $order
         */
        function process_woo_wallet_general_cashback_callback($process, $order){
            if($order->get_coupons()){
                $process = false;
            }
            return $process;
        }
    }
    Thread Starter Hassan Yousuf

    (@hassanyousufx)

    Solved!

    Thread Starter Hassan Yousuf

    (@hassanyousufx)

    Hi, can you also tell me if we disable cashback for on-sale items?

    Plugin Author Subrata Mal

    (@subratamal)

    Hi @hassanyousufx

    Please use the attached updated code.

    add_filter('process_woo_wallet_general_cashback', 'process_woo_wallet_general_cashback_callback', 10, 2);
    if (!function_exists('process_woo_wallet_general_cashback_callback')) {
    
        /**
         * 
         * @param type $process
         * @param WC_Order $order
         */
        function process_woo_wallet_general_cashback_callback($process, $order) {
            if ($order->get_coupons()) {
                $process = false;
            }
            if (sizeof($order->get_items()) > 0) {
                foreach ($order->get_items() as $item_id => $item) {
                    $product_id = $item->get_product_id();
                    $product = wc_get_product($product_id);
                    if($product->is_on_sale()){
                        $process = false;
                    }
                }
            }
            return $process;
        }
    
    }
    Thread Starter Hassan Yousuf

    (@hassanyousufx)

    Hi,

    The above updated code will not apply cashback if one of the items are on sale. Can we apply cashback only on non sale items?

    Because even if out of 20 products, 1 product is on sale then the it won’t apply the cashback. Can you please update the code so that it applies cashback only on 19 items and excludes the 1 item that was on sale?

    Thank you.

    Plugin Author Subrata Mal

    (@subratamal)

    @hassanyousufx Please use the attached updated code.

    add_filter('process_woo_wallet_general_cashback', 'process_woo_wallet_general_cashback_callback', 10, 2);
    if (!function_exists('process_woo_wallet_general_cashback_callback')) {
    
        /**
         * 
         * @param type $process
         * @param WC_Order $order
         */
        function process_woo_wallet_general_cashback_callback($process, $order) {
            if ($order->get_coupons()) {
                $process = false;
            }
            return $process;
        }
    
    }
    
    add_filter('woo_wallet_product_wise_cashback_amount', 'exclude_on_sales_products', 10, 2);
    add_filter('woo_wallet_product_category_wise_cashback_amount', 'exclude_on_sales_products', 10, 2);
    
    if(!function_exists('exclude_on_sales_products')){
        function exclude_on_sales_products($cashback_amount, $product){
            if($product->is_on_sale()){
                $cashback_amount = 0;
            }
            return $cashback_amount;
        }
    }

    Not working for me.

    Yes, Not working for me also.

    Don’t apply cashback if coupon is applied – Please share any possible.

    Plugin Author Subrata Mal

    (@subratamal)

    @selvamkanthasamy2022 Where did you put this code?

    add_filter('process_woo_wallet_general_cashback', 'process_woo_wallet_general_cashback_callback', 10, 2);
    if (!function_exists('process_woo_wallet_general_cashback_callback')) {
    
        /**
         * 
         * @param type $process
         * @param WC_Order $order
         */
        function process_woo_wallet_general_cashback_callback($process, $order) {
            if ($order->get_coupons()) {
                $process = false;
            }
            return $process;
        }
    
    }
Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Don’t apply cashback if coupon is applied’ is closed to new replies.