Check Here
Check Here

How to create Custom Shipping Method in Bagisto ?

Shipping Method

It becomes very easy to create custom Shipping Methods in bagisto for both (i.e. Novice developer as well as Professional Developers). As the diversity of shipping methods provide the options to customer for various shipments when they proceed to checkout. On another perspective, multiple shipping methods are a great strategy to reach out to the global marketplace.

There are basically two ways to create Custom Shipping Methods in bagisto.

Package Generator

If you are using bagisto 1.2.0 or above, what you can do is, You can simply run the command below which will make appropriate directory structure for you which will be used further.

If, in case your Package Name already exist at the same directory, you can also use –force with the above command which goes like this:

Manual Way

You have to create the directory structure of your own. Follow and create the directory structure mentioned below.

You have to create the directory structure of your own. Follow and create the directory structure mentioned below.

Create this directory structure to create your payment method.

The user needs to create a file named carriers.php at the src/config path in the package (say FedEx). Here, we are going to specify what to include in your carriers.php file.

Step 1: Add your Shipping method in Admin panel

  1. Go to Config folder present inside your package -> src.
  2. Now you have to add some keys and there values which helps you adding you shipping Method at the admin end Configuration.
  3. You can use the keys below and edit at your own end according to the need of yours.

What this will do is, It will create the fields in the admin end where you can configure your settings. It will look like this:

Step 2: Render Shipping Method at checkout

In order to render your custom shipping method at the checkout process, you just need to define ‘calculate()’ within your DemoShipping.php and return shipping rate, shipping title, shipping description within an object.

You can refer to the code below.

After doing all these things and enabling payment method from the admin end, you’ll be able to see the shipping method at the front end at the time of checkout.

Rest Important folders

  • Within Database folder, the migration and seeder(if needed) files are stored.
  • Within Resources folder your views as well as your raw, un-compiled assets such as SASS, or JavaScript. This directory also houses all of your language files.
  • Within Providers folder all of the service providers for your application. Service providers bootstrap your application by binding services in the service container, registering events, or performing any other tasks to prepare your application for incoming requests.Here, in our case, we have created two providers files i.e.,
    1. EventServiceProvider : In this file, events included with your application provides a convenient place to register all of your application’s event listeners.
    2. PaymentServiceProvider : In this file, you may register all your configuration, language, and routes within register and boot methods.
  • Within Models folder, the models are stored for the application.
  • Within Payment folder, write the code needed to operate your payment method
  • Within Repositories folder, create a file as HelloWorldRepository.php which must extend repository class
  • Within Http folder, define your routes and controller application.
  • Within Listeners folder, this folder includes listener files to listen to respective events.
. . .

Comments (10)

Add Your Comment

  • Abbas
    From where did the 10$ came from ?
    Also how can do i it based on certain city?
    • Sanjana Singh
      Hello Abbas,

      Greetings for the day!!

      In the above screenshot, we used flat rate shipping so there is a configuration for flat rate shipping(configure>>sales>>shipping method), you can set the shipping rate from there.

      For a certain city- we do have a table rate shipping module, where you can set the shipping cost on the basis of zip code.
      https://bagisto.com/en/extensions/laravel-ecommerce-table-rate-shipping/

  • Antonio Peña
    Looks like you guys always forget to add something on the instructions…. I have followed thew video and the Blog instructions for this and for a new payment method, and the options are not appearing on the Admin.
    • Sanjana Singh
      Hello Antonio,

      Greetings for the day!!

      Sorry for the inconvenience, please run the below command and also check the below link.

      composer dump-autoload
      PHP artisan config: cache

      • Andrew
        Hey, I am having the same issue ofr both payment and shipping methods. I have cleared config and still nothing showing.
  • styles
    Bro, where is my new shipping method? They are not showing up at the admin panel shipping options.
    I’m using the “php artisan package:make-shipping-method ACME/FedEx”. In the end they are not showing up.
    I also tried composer dump-autoload and PHP artrisan config:clear
    Still facing the issue.
  • Bram
    Hello, can you help me? It seems my custom shippings costs works everywhere except in the order confirmation mail to the client?
  • Bagisto helped us in creating this full functional, professional and user friendly web app. Bagisto has lot to offer to the developer and the user. The framework is outstanding.

    Yosseph Baruch Dolgopolsky

    Yosseph Baruch Dolgopolsky

    allspot.store
    Talk to Sales

    Global

    Live Chat
    Start a Project

      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home
      css.php