Custom Delivery Provider: Display List of Rates

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
CanLikeTo
Posts: 6
Joined: 17 Jun 2024, 19:16

Custom Delivery Provider: Display List of Rates

Post by CanLikeTo » 17 Jun 2024, 19:22

Hi, I'm implementing a Delivery provider for a courier service and I'd like to display a list of options for the customer during the checkout process. The courier allows for you to get a quote based on the address and packages with different rates.

I'd like to display these rates to the customer for them to choose and then use later when the purchase is completed.

What would be the best way of doing this? I was thinking of returning a list when

Code: Select all

setConfigFE()
is called, but I'm not sure.

PHP Version: 8.3.8
Aimeos Version: 2024.04.*
Environment: Mac OS 13.6.2

User avatar
aimeos
Administrator
Posts: 8620
Joined: 01 Jan 1970, 00:00

Re: Custom Delivery Provider: Display List of Rates

Post by aimeos » 18 Jun 2024, 08:50

It's one option to return an entry in getConfigFE() with a "list" configuration but that has limitations displaying the price (you would have to do that in the label). Another option might be to return several delivery options, e.g. for standard or express delivery.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

CanLikeTo
Posts: 6
Joined: 17 Jun 2024, 19:16

Re: Custom Delivery Provider: Display List of Rates

Post by CanLikeTo » 18 Jun 2024, 11:04

Great thanks. Can I generate these on the fly or do they have to be configured ahead of time? Where can I hook into this? So, basically my plan is as follows:
  1. Fetch the list of rates and delivery options and display it when the delivery options step is shown during the checkout process.
  2. Add it to the context of the basket.
  3. Use the selected value in from 1. and and the values stored in the context to create a shipment when the purchase is completed.

User avatar
aimeos
Administrator
Posts: 8620
Joined: 01 Jan 1970, 00:00

Re: Custom Delivery Provider: Display List of Rates

Post by aimeos » 18 Jun 2024, 20:06

If you want to use several delivery options, you have to create them ahead of time but the price can be dynamic. If you want to have a totally dynamic selection, than the list entries you can create in getConfigFE() are better.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

CanLikeTo
Posts: 6
Joined: 17 Jun 2024, 19:16

Re: Custom Delivery Provider: Display List of Rates

Post by CanLikeTo » 19 Jun 2024, 06:34

Thanks, would it be possible to create the full set of options ahead of time, but then only display the available ones based on the quote?

User avatar
aimeos
Administrator
Posts: 8620
Joined: 01 Jan 1970, 00:00

Re: Custom Delivery Provider: Display List of Rates

Post by aimeos » 19 Jun 2024, 17:42

Yes, if you return true/false in the isAvailable() method of the service provider. Only those for which true is returned are shown.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

CanLikeTo
Posts: 6
Joined: 17 Jun 2024, 19:16

Re: Custom Delivery Provider: Display List of Rates

Post by CanLikeTo » 20 Jun 2024, 11:48

Great, thank you very much for your help.

CanLikeTo
Posts: 6
Joined: 17 Jun 2024, 19:16

Re: Custom Delivery Provider: Display List of Rates

Post by CanLikeTo » 27 Jun 2024, 16:00

Hi,

I'm caching the shipping rates and I'd like to use the basket ID in the key. How to I access it inside the isAvailable method? As far as I can see, the order gets passed in, but it has no ID yet.

User avatar
aimeos
Administrator
Posts: 8620
Joined: 01 Jan 1970, 00:00

Re: Custom Delivery Provider: Display List of Rates

Post by aimeos » 30 Jun 2024, 13:12

No, the order will get an ID when it's stored in the mshop_order tables. As long as it's only a non-permanent basket, you can use the session token:

Code: Select all

$this->context()->token()
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

CanLikeTo
Posts: 6
Joined: 17 Jun 2024, 19:16

Re: Custom Delivery Provider: Display List of Rates

Post by CanLikeTo » 01 Jul 2024, 08:00

Got it, thanks.

Post Reply