Help for integrating the Laravel package
Forum rules: Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
#5667 by Travin
10 Feb 2018, 04:50
Hey guys
Could you explain me how can I access order products data during the checkout process? I'm trying:
Code: Select allpublic function process( \Aimeos\MShop\Order\Item\Iface $order, array $params = [] )
    {
$orderBaseItem = $this->getOrderBase( $order->getBaseId() ); 
 print_r(get_class($orderBaseItem));  // Aimeos\MShop\Order\Item\Base\Standard
 echo '<br/>PRODUCTS:<br/>';
print_r($orderBaseItem->getProducts());
}

$orderBaseItem->getProducts() returns me an empty array.
But it saved at DB well, and I can access all products data at Orders History page from the same object Aimeos\MShop\Order\Item\Base\Standard.
But I need it at my process() too.
Thanks!
#5674 by aimeos
12 Feb 2018, 22:46
There's a second parameter for the getOrderBase() method:
https://github.com/aimeos/aimeos-core/blob/master/lib/mshoplib/src/MShop/Service/Provider/Base.php#L523

Pass one of these as second parameter:
Code: Select all$parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_SERVICE | \Aimeos\MShop\Order\Item\Base\Base::PARTS_PRODUCT;
$parts = \Aimeos\MShop\Order\Item\Base\Base::PARTS_ALL;

The second one will also fetch address and coupon data (https://github.com/aimeos/aimeos-core/blob/master/lib/mshoplib/src/MShop/Order/Item/Base/Base.php#L28)