get product data at checkout process

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Travin
Posts: 70
Joined: 18 Dec 2017, 03:12

get product data at checkout process

Post 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 all

public 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!
Laravel 6.18.19 | php 7.4.7 | Xubuntu | Aimeos Laravel 2019.10.5

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: get product data at checkout process

Post by aimeos » 12 Feb 2018, 22:46

There's a second parameter for the getOrderBase() method:
https://github.com/aimeos/aimeos-core/b ... e.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/b ... se.php#L28)
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply