Bagisto Forum

    Bagisto

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    How to calculate FlatRate Shipping based on Shipping City field?

    Knowledge Base
    2
    3
    391
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Z
      Zakir last edited by

      Hi,
      How to calculate FlatRate Shipping based on Shipping City field?
      my requirement is simple, for a one City say 'Dhaka' is 60 BDT and rest of others 130 BDT ..
      How to achieve this
      I am looking into this code ..
      If I can get City filed value know which source file to change , I think it can implement easily.
      https://github.com/bagisto/bagisto/blob/master/packages/Webkul/Shipping/src/Carriers/FlatRate.php#L28

      Thanks.

      1 Reply Last reply Reply Quote 0
      • O
        otheriz last edited by

        in that file on line #34, there's a $cart variable..
        you can use like $cart->shipping_address->city ...or whatever the address field available..

        you can comment(disable) the script of the current calculation..or you can overwrite the calculation by inserting something like this before the "return $object" ...

        if($cart->shipping_address->city == "Dhaka"
        {
                    $object->price = 60;
                    $object->base_price = 60;
        }else{
                    $object->price = 130;
                    $object->base_price = 130;
        }
        
        1 Reply Last reply Reply Quote 0
        • Z
          Zakir last edited by

          Thank you very much, i have implemented that.

          6ef4474f-fd9f-42a1-a2a8-d11fe92f5fbe-image.png

          1 Reply Last reply Reply Quote 1
          • First post
            Last post