From 43aaafc68c72c09982bd9fa440f821aacf722eec Mon Sep 17 00:00:00 2001 From: Magdalena Sadowska Date: Tue, 5 Nov 2024 12:49:20 +0000 Subject: [PATCH] GITBOOK: Export Sylius documentation --- docs/.gitbook/assets/sylius_shipment.webp | Bin 0 -> 3408 bytes docs/the-book/carts-and-orders/shipments.md | 114 +++++++++++++++++++- 2 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 docs/.gitbook/assets/sylius_shipment.webp diff --git a/docs/.gitbook/assets/sylius_shipment.webp b/docs/.gitbook/assets/sylius_shipment.webp new file mode 100644 index 0000000000000000000000000000000000000000..6f1aada4bd82731332daedd76e2a8b3ec7f57787 GIT binary patch literal 3408 zcmZ8jc{~$<`<`oa&k-YQP`}zI%d_K?nzR&x9oeVrY^X!1#Av~x9&Ir5pJi>v|1T(%8SgGk*8lQig6R>$;66PLpG5LwYWLUGTB zy*|bf_K+z`;smvgUFJ=ckf$R^R)fMOz7Yi>!zOiG87hMZb`$f+$UP2$b{+{z^OhSK zs*FnBe61=^_#qJ&T8RJi!a{a>xY(x4Vquc7CNlMTVl}ewC+Ws3bUYfkEax$S$~owm z4toeYEdxV1RovBa=cml68&s(Z>8g{NCs0*Dbd-iNI#>3}3mOFGD4leKPai@i`t^0r5Xq^r) z%Z*WYc^+;zuo7N!d=)cuZ29)bCn3utMeG=+TzlYt z=u5mZ5$s$ecssN_=kg2EgA-PEwRO|R2RO{y84!=U_m~ExqbviYJjwa>4tJP57R_Ju zhB$Hwf=TB`I-Kk9b7yI(-dY2$&SJyi3+S4|u zz%{hEvc4(F+D~~Gtx=H&8DI88#0*Z>wKq<(@Nb)8AKtb(J56j+(KlY@?si90Qtilp z*GxAFYNhHsbNDrL(w!_r%!gwoeZ&)O23^dT?q6mONpklC_iq&we_yIxKJGz1iS=&; z-!1+8u|U{1FoJ9o#G08|cK_*IY??{UTQzaSPb(~<^R=U+X1;&p7T=?{?%x=Yz~O|f zvaOmYyBElJzv4kdndB;i6(PpYU8@m{5=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U8lmk0umS^Tc3*#p=LSwQDDd7ZyNqR%mgigw z&Xokng)8!&EU${mI|~ZzdFKYMf4yy@MT$W;8+w^r5|G24cV#ph9MnltUk}g5>~d7U zcC)_uM5a5$vq&p*BC{YA(P(5_7vcx^|8-`)OQ%t+@!S;+Pg#|>1#jxF-GeSxd*2Xz z@lvE;gm6)iKBkWtS@v>EDsgg6XNwOxglVJ}6H-*03`NIP#J-0hdqSm9&m&2tt0IY*Xp%vyP)&yf7e`E!EupEqCrjt!$~uNTbFF zIL@q*SQUW@YaJ&7bJEf|7Xsfw&(3SnpQe`b+*x(xmg%nNYgc0nRx9X# zUIB8o_%{jnPs0D7#NdBR*#9HE|4UmN`>(@pReLGaf;Ig2>~j2=Kc~YrBrm_NZM==i zdrd+qft|ae9ZR;;XQZ?7q1VlemSeS*ObxhCewa7_PZzc|N&d0_-c~(D({7-wwmgHs z1nk?(If~?VwZ5y4xY35(Ua91 z@HK@{-s@d#J%E&WpkOqUhv6+iP6^dAd!&&dQj_>W-A@Rl({Tx=P8|;Bj6!h_3_C8& z;)p69f<`J3nIzA+AsR~(A@j%V640)&fqUT`l+-V>ot0=zovUUNd;U!_3W|?juy613 zsIAn5h0P0V*kqxaTwi|g>v=rVVKC^Vq3ORv+$jQhp$wyR4uRDOyS^{HxR1>u6qjI= zhTHZ+Jr`cxP!;OrHsl>BDbiNOuz>+*LFHz%@(Z`^Cmj`~L5ev$D}3FzUIAD%TLES= zikvo;?233%8_2x6>#GBQmh;bYr6xB_;`?)4ITEDp4@GCAQ`h+H;~(4$F>kxhg zIcD_Zpz3skK3&I5dfe$NoH@g4kn*R+r^d7nY0O#g{w*UYD literal 0 HcmV?d00001 diff --git a/docs/the-book/carts-and-orders/shipments.md b/docs/the-book/carts-and-orders/shipments.md index 626579efcf..5f7508e1c8 100644 --- a/docs/the-book/carts-and-orders/shipments.md +++ b/docs/the-book/carts-and-orders/shipments.md @@ -1,6 +1,118 @@ --- -hidden: true +layout: + title: + visible: true + description: + visible: false + tableOfContents: + visible: true + outline: + visible: true + pagination: + visible: true --- # Shipments +A shipment represents a shipping request for an order in Sylius. Each order can have multiple shipments, and each shipment is made up of `ShipmentUnits`, which correspond to `OrderItemUnits` from the order. + +## Creating a Shipment for an Order + +{% hint style="info" %} +To understand the process of creating shipments, refer to the guide on [Orders](orders.md) where shipments are covered in detail. +{% endhint %} + +### Splitting Shipments + +In Sylius Plus, orders can be fulfilled partially, allowing for shipment splitting. This feature provides a UI where you can select items from an existing shipment to create a new one and send it (with or without a tracking code). Shipments can be split as long as at least one shipment remains in the `ready` state. + +### Shipment State Machine + +Each shipment has its own state machine with these states: `cart`, `ready`, `cancelled`, `shipped`. + +**Available Transitions:** + +``` +transitions: + create: + from: [cart] + to: ready + ship: + from: [ready] + to: shipped + cancel: + from: [ready] + to: cancelled +``` + +
+ +## Shipping Methods + +A `ShippingMethod` in Sylius represents how an order is shipped to a customer. + +**Creating a ShippingMethod Programmatically:** + +```php +$shippingMethod = $this->container->get('sylius.factory.shipping_method')->createNew(); +$shippingMethod->setCode('DHL'); +$shippingMethod->setCalculator(DefaultCalculators::FLAT_RATE); +$shippingMethod->setConfiguration(['channel_code' => ['amount' => 50]]); + +$zone = $this->container->get('sylius.repository.zone')->findOneByCode('US'); +$shippingMethod->setZone($zone); + +$this->container->get('sylius.repository.shipping_method')->add($shippingMethod); +``` + +To make a shipping method available during checkout, add it to a channel: + +```php +$channel = $this->container->get('sylius.repository.channel')->findOneByCode('channel_code'); +$channel->addShippingMethod($shippingMethod); +``` + +### Shipping Method Rules + +Rules define when a shipping method is available. Each rule type has a `RuleChecker` that checks conditions like: + +* All products in a certain taxon +* Order total greater than a specific amount +* Total weight below a certain number +* Total volume below a certain value + +**Rule Types:** + +* **Items total greater than or equal** +* **Items total less than or equal** +* **Total weight greater than or equal** +* **Total weight less than or equal** + +## Shipping Zones + +Shipping zones specify where shipping methods apply. For example, you can configure methods for specific countries. Ensure that each `ShippingMethod` is assigned to the correct zone, as the available methods are based on the customer’s address. + +## Shipping Cost Calculators + +Shipping cost calculators determine the cost of a shipment. The `CalculatorInterface` has a `calculate()` method that takes a configuration object and returns the shipping cost. The `DelegatingCalculator` selects the appropriate calculator type based on the `ShippingMethod`. + +Example: + +```php +$shippingCalculator = $this->container->get('sylius.shipping_calculator'); +$cost = $shippingCalculator->calculate($shipment); +``` + +### Built-in Calculators + +Sylius includes these built-in calculators: + +* **FlatRateCalculator**: Returns a fixed amount from the `ShippingMethod` configuration. +* **PerUnitRateCalculator**: Multiplies the configuration amount by the number of units. + +## Shipment Complete Events + +These events are triggered when a shipment is marked as shipped: + +* `sylius.shipment.pre_ship` +* `sylius.shipment.post_ship`