Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

"Shipping gateways and providers" documentation - a few questions

Vote:
 

I'm trying to create a new shipping provider and a plugin via the Commerce documentation "Shipping gateways and providers" (link at the very bottom) and have some feedback and questions regarding the documentation:

1. First, it's unknown how to use these code snippets. Would be nice to have a whole method or even class included in the code example.
2. "Remember to register the class with the service container as a service of IShippingPlugin." - It would be nice to have an example (interface for registration and suggested lifetime of the plugin).
3. "ShippingManager.GetShippingMethodCases(methodId, shippingAddress.CountryCode ..." < where is the shippingAddress coming from? Now, I see it might be a shipment.ShippingAddress, but it's not explicitly said.
4. "Accessing shipping provider information" > What should happen after retrieving "cases"? It's unclear to the reader. Also, it's unknown how this might be populated.
5. "For information about using this DataTable, see the WeightJurisdictionGateway.cs GetRate() implementation." > Well, it's still unclear what to do now. Should readers google that class (cannot find the source code online) or decompile sources and see decompiled and rather hard-to-read code?
6. "Copy the .dlls associated with the project where the shipping gateway is implemented to the bin folders of the Commerce Manager and public websites." > It's totally unknown what's that bin folder and where to find it (is it bin/[debug|release]?). I'm using .NET 6 (non-IIS) - where should this .dll copy to? It would be also nice to see if the app should be started if the DLL file has been added during a runtime.

My general feeling about that page is that it provides different code snippets, but the general overview is unknown. It's very difficult to follow these steps in order to create own shipping plugin.

Documentation URL: https://docs.developers.optimizely.com/commerce/v14.0.0-commerce-cloud/docs/shipping-gateways-and-providers

#284738
Edited, Aug 01, 2022 9:07
Vote:
 
  1. https://docs.developers.optimizely.com/commerce/v14.0.0-commerce-cloud/docs/shipping-gateways-and-providers does a good job describing what you need to build a IShippingPlugin.
  2. Lifetime of the plugin is upto you. Most clients will use Transient but other clients focused on performance may use Singleton or Scoped, but that relies on heavier testing and careful consideration of the calling context.
  3. You're implementing an IShippingPlugin so the input is an address and the output is a rate. The shippingAddress.CountryCode is obtained by your own website in whatever user journey you've created. Usually the customer fills in a address form when they are checking out right?

4,5 and 6. It seems to me based on your questions, you may not need to create a custom shipping provider. You simply need to create a shipping method via the admin interface. The documentation incorrectly refers to Commerce Manager which is Commerce 13 and below. In Commerce 14 everything as been moved to edit mode.

Apologies if I've misunderstood your post and you do need to write an external shipping provider with custom logic, let me know and I'll try to help you further.

#284740
Aug 01, 2022 9:32
Vote:
 

Thank you for the answer, Surjit.

A.d. 1: Yes, but it has some flaws, ambiguities and missing pieces :)

A.d. 2: It's still not very clear to me how to register that plugin correctly. When dealing with, let's say, ShippingManager dependency, which lifetime would be more suitable for the shipping plugin? Or, how that should be registered via DI container for more than one plugin? My point is that has not been properly covered in the documentation.

A.d. 3: I see. However, that assumption has not been covered in the Documentation. shippingAddress comes from nowhere and it would be more convenient if a proper assignment (e.g. from shipment) would be included in that piece of code.

For 4-6: That's fine, I was able to find the panel and all the missing via trial and error. However, this should be included in the documentation.

#284748
Aug 01, 2022 10:56
Vote:
 

Hi Dariusz,

Register it directly adding [ServiceConfiguration(ServiceType = typeof(IShippingPlugin))] to the top of your class.

#284752
Aug 01, 2022 12:25
Vote:
 

Yes, this is what I'm talking about - that simple information about registration should be added to the Documentation. Plus, information about more complex scenarios would be nice to have as well.

#284753
Edited, Aug 01, 2022 12:44
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.