• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Register
  • Login
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 7 Nov 2020, 09:20

    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 7 Nov 2020, 11:50

      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 9 Nov 2020, 10:45

        Thank you very much, i have implemented that.

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

        1 Reply Last reply Reply Quote 1
        1 out of 3
        • First post
          1/3
          Last post