![]() You can use it to define shipping prices based on subtotal order price (that is price without any order adjustments) or total order price. ![]() So, I created another condition called Limit by order price range. You cannot use it to define shipping costs based on the total amount of products in the cart for ranges. The same thing is with Limit by total condition. Shipping 1-10kgĪnd this is how the Shipping information checkout pane will look like if total weight sum of all products in the cart is between 1 and 10 kilograms. For weight range between 10 and 20 kilograms you can define another shipping price and so on. For example if total weight of all products in the cart is between 1 and 10kg you can set one shipping price. You can use it to define shipping methods for a specific weight range. To fix this problem I created Limit by shipment weight range condition. Defining these shipping methods with Limit by shipment weight condition cannot be done, because it does not allow defining weight ranges. Let's say that you have different shipping prices for different product weights. But in some cases these conditions are not good enough for restricting shipping methods. * Sets the shipment amount to a fixed value.By default Drupal Commerce 2.x and Commerce Shipping modules come with two nice conditions Limit by total price and Limit by shipment weight. And we start with the plugin annotation: /** OK, now that we have a bit of background on where in the code we need to look for inspiration, let’s create our own plugin called ShipmentFixedAmount, which will extend from ShipmentPromotionOfferBase. All the plugin has to do is handle the actual offer application and potentially the configuration form for it (as needed). So the base class takes care of the form and that logic already for us. For instance, when dealing with shipping, we can condition the plugin to a given shipping method. The reason for these base classes is to provide some specific logic that deals with the type of offer “target”. We also have similar for order items, some others, but finally, what we care about is the ShipmentPromotionOfferInterface and ShipmentPromotionOfferBase, which we will be using. For example, we have OrderPromotionOfferInterface and it’s corresponding OrderPromotionOfferBase that deal with orders. Search for jobs related to Drupal commerce drop shipping or hire on the worlds largest freelancing marketplace with 22m+ jobs. So for this reason, we also have interfaces and base classes for the plugins that deal specifically with a type of offer “target”. ![]() For example, shipment costs, the order total as a whole, individual order item prices, etc. ![]() Typically, promotion offers are applied to something. I highly recommend you check out the code for all the existing ones and find inspiration from there. The latter is responsible for taking an entity and applying the offer onto it. The promotion offer plugins implement PromotionOfferInterface with its most important method: apply(). So, if you check in your current Drupal commerce installation, the offer type from the screenshot above doesn’t exist yet. Namely, creating an offer type that reduces the shipping rate by either a percentage amount or by a fixed amount: Because otherwise I can immediately refer you back up to all the things Drupal commerce can do out of the box. Of course, the main premise here is that your shipping costs are variable and depend on the things people buy (such as weight and stuff).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |