Question on Ship Separately / Custom Product Type

161 views
Skip to first unread message

Jon Culver

unread,
Apr 9, 2014, 2:46:46 PM4/9/14
to ship...@googlegroups.com
Hello,

This seems like the best place for a high level, non-urgent question, but let me know if there's a better venue...

I'm creating a new product type. It's like a configurable, but points to multiple simple products instead of just a single, like how the stock configurable products work.

I'm curious how the parent / child products should relate to eachother in order to play nice with ShipSync. Specifically, this bit:


isShipSeparately() seems to only pertain to bundled products, is that correct? Can any one shed more light on the intent, and why these lines do what they do? (Feel free to respond in very basic / "dumb question" terms, that's kind of my point :D)

Thanks!

Jon

Jon Culver

unread,
Apr 10, 2014, 1:38:49 PM4/10/14
to ship...@googlegroups.com
I think I've found my answer with some more digging:


Ship Separately is part of Bundle products only. Those lines I linked to before in the ShipSync module just say, if we're dealing with a bundle product and shipping every together, then ignore the child products and focus on the parent. If we're shipping everything separate, ignore the parent (it's just a placeholder) and focus on the child items. Makes sense.

Ship Together is the default. I think for my use case I'll be setting the option to ship separately. Hope this helps somebody else down the road!

Cheers,

Jon

David Kirby

unread,
Apr 22, 2014, 2:55:59 PM4/22/14
to ship...@googlegroups.com
Yup, that's right.

Here's Magento's method for reference ->


/**
     * Return items for further shipment rate evaluation. We need to pass children of a bundle instead passing the
     * bundle itself, otherwise we may not get a rate at all (e.g. when total weight of a bundle exceeds max weight
     * despite each item by itself is not)
     *
     * @param RateRequest $request
     * @return array
     */
    public function getAllItems(RateRequest $request)
    {
        $items = array();
        if ($request->getAllItems()) {
            foreach ($request->getAllItems() as $item) {
                /* @var $item \Magento\Sales\Model\Quote\Item */
                if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
                    // Don't process children here - we will process (or already have processed) them below
                    continue;
                }

                if ($item->getHasChildren() && $item->isShipSeparately()) {
                    foreach ($item->getChildren() as $child) {
                        if (!$child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
                            $items[] = $child;
                        }
                    }
                } else {
                    // Ship together - count compound item as one solid
                    $items[] = $item;
                }
            }
        }
        return $items;
    }


ShipSync's logic is nearly the same, excepting an allowance for a possible child item shipped separately (to account for special packaging).
Reply all
Reply to author
Forward
0 new messages