Okay
  Public Ticket #3389440
Change the Default COD Orders to (Reversed) in special case.
Closed

Comments

  •  5
    ABDULRAHMAN started the conversation

    Dear Stefan,

    Because usually we deliver to the customers, so usually COD orders are None:

    6184369142.png



    But sometimes the customer can choose one of these shipping methods (), So I would like to make a condition that make the COD order (Reversed) If only the customer chosen one of these shipping methods in checkout (Vendor Delivery) or (Local Pick-up From Vendor)


    4569822482.png


    Thank you

  •  2,167
    WebWizards replied

    Hi there,

    I made a modification to MarketKing Core (attached) that adds a new hook to assist with this. Please first update to the attached version.


    We can then use this hook and code snippet to determine if the COD reverse behaviour can be applied or not:

    add_filter('marketking_apply_cod_reverse', function($apply, $order){
        
        return $apply; // true or false
    }, 10, 2);
    


    Specifically to allow cod reverse only for local pickup and vendor shipping I believe you can use:

    add_filter('marketking_apply_cod_reverse', function($apply, $order){
        $method = reset($order->get_shipping_methods())->get_method_id();
        if ($method === 'marketking_shipping' || $method === 'local_pickup'){
            // continue
        } else {
            $apply = false;
        }
        
        return $apply; // true or false
    }, 10, 2);
    


    Kind regards,

    Stefan


    Attached files:  marketking-core-1623.zip