Bagisto Forum

    Bagisto

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

    Create Custom Shipping Method - Not Showing in Admin Dashboard

    General Discussion
    2
    8
    1139
    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.
    • R
      rudiculous last edited by

      Hello,

      So I have created the custom shipping method using Bagisto Package Generator with command "php artisan package:make-shipping-method ACME/DHL"

      also have done this command "php artisan package:make-shipping-method ACME/DHL --force"

      I can see files are generated under packages/ACME folder.
      I have done clear config, cache and dump-autoload too.

      But I still cannot see the shipping method in the Admin dashboard. Anything I missed out?

      Thanks!

      1 Reply Last reply Reply Quote 0
      • R
        rudiculous last edited by

        How about this? do you have any idea what is happening? @Vaishali-Agarwal

        1 Reply Last reply Reply Quote 0
        • devansh-webkul
          devansh-webkul last edited by

          Hi @rudiculous,

          Did you register your custom provider in the config/app.php and composer.json file?

          1 Reply Last reply Reply Quote 0
          • R
            rudiculous last edited by

            Thanks @devansh-webkul for the response.
            I have resolved this issue. But I have one more question to ask.

            So in my custom shipping method file /packages/ACME/DHL/src/Carriers/DHL.php

            public function calculate()
                {
                    if (! $this->isAvailable()) {
                        return false;
                    }
                    //I want to calculate the shipping fee here by calling some of my api provider
                    //how I can get the current address from the form that the customer filled up, so I can get the city, postal code, etc?
                    //I also need the total weigh of the cart, how to get that from this function?
                    // so eventually i can override the object price before return $object->price
            
                    $object = new CartShippingRate;
                    $object->carrier = 'dhl';
                    $object->carrier_title = $this->getConfigData('title');
                    $object->method = 'dhl_dhl';
                    $object->method_title = $this->getConfigData('title');
                    $object->method_description = $this->getConfigData('description');
                    $object->price = 0;
                    $object->base_price = 0;
            
                    return $object;
                }
            
            1 Reply Last reply Reply Quote 0
            • devansh-webkul
              devansh-webkul last edited by

              Customer address will save in the cart. You can fetch from it.

              1 Reply Last reply Reply Quote 0
              • R
                rudiculous last edited by

                @devansh-webkul how to fetch? what function or variable I can use to fetch it?

                1 Reply Last reply Reply Quote 0
                • devansh-webkul
                  devansh-webkul last edited by

                  Grab the cart based on the customer. You can use the Cart facade or helper. Fore e.g.,
                  Cart::getCart() or cart()->getCart()

                  This will give you the current customer's cart. Now from here rest is mattered the relationships. Just go thorught your cart model and check the relationshiop.

                  1 Reply Last reply Reply Quote 0
                  • R
                    rudiculous last edited by

                    @devansh-webkul Okay thank you. I will try with this.

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