What I’m trying to achieve
During the checkout, if the customer has a Bike item in their basket, we want the shipping cost to be added as a product option to the cart item as opposed to being added to the cart. This is because for Bike items the client wants the customer to ONLY pay £99 as a deposit, without having to pay the, e.g. £120 dispatch fee; they want the dispatch fee to be added to the Bike’s options.
What we’ve done
I’ve created a plugin for MagentoCheckoutModelShippingInformationManagement::saveAddressInformation
(RichardPKDeliveryChargePluginCheckoutModelShippingInformationManagement::afterSaveAddressInformation
) where I’m listening for the shipping method “tablerate_bestway” and, if the basket has a Bike item in it, am setting the shipping information to “0.00” then, for each item, finding each Bike item in the basket, adding the Additional Option “Delivery Fee” and the shipping amount. These values are being saved to the database and I can see the values being updated. I’m also able to see the values being updated in the JSON being returned to the /rest/abtesting/V1/guest-carts/<cart-id>/shipping-information
request BUT the sidebar summary block details are not being updated, i.e. the shipping amount still shows £120 and the cart item’s options do not include the shipping fee.
What do I need to change in order to achieve what I’m trying to do?