/** * @constructor * @param FixtureInterface $product */ public function __construct(FixtureInterface $product) { parent::__construct($product); /** @var BundleProduct $product */ $bundleSelection = $product->getBundleSelections(); $checkoutData = $product->getCheckoutData(); $checkoutBundleOptions = isset($checkoutData['options']['bundle_options']) ? $checkoutData['options']['bundle_options'] : []; foreach ($checkoutBundleOptions as $checkoutOptionKey => $checkoutOption) { // Find option and value keys $attributeKey = null; $optionKey = null; $productKey = null; foreach ($bundleSelection as $key => $option) { if ($option['title'] == $checkoutOption['title']) { $attributeKey = $key; $optionKey = $checkoutOptionKey; } foreach ($option['assigned_products'] as $keyProduct => $product) { $productKey = $keyProduct; } } // Prepare option data $bundleOptions = $bundleSelection[$attributeKey]['assigned_products'][$productKey]; $value = $bundleOptions['sku']; $qty = isset($checkoutOption['value']['qty']) ? $checkoutOption['value']['qty'] : $bundleOptions['selection_qty']; $price = number_format($checkoutData['cartItem']['options']['bundle_options'][$optionKey]['price'], 2); $optionData = ['title' => $checkoutOption['title'], 'value' => "{$qty} x {$value} {$price}"]; $checkoutBundleOptions[$checkoutOptionKey] = $optionData; } $this->data['options'] += $checkoutBundleOptions; }
/** * @constructor * @param FixtureInterface $product */ public function __construct(FixtureInterface $product) { parent::__construct($product); /** @var GiftCardProduct $product */ $checkoutData = $product->getCheckoutData(); $optionsData = $checkoutData['options']['giftcard_options']; $cartItemOptions = [['title' => 'Gift Card Sender', 'value' => "{$optionsData['giftcard_sender_name']} <{$optionsData['giftcard_sender_email']}>"], ['title' => 'Gift Card Recipient', 'value' => "{$optionsData['giftcard_recipient_name']} <{$optionsData['giftcard_recipient_email']}>"]]; $this->data['options'] = isset($this->data['options']) ? array_merge($this->data['options'], $cartItemOptions) : $cartItemOptions; }
/** * @constructor * @param FixtureInterface $product */ public function __construct(FixtureInterface $product) { parent::__construct($product); /** @var DownloadableProduct $product */ $checkoutDownloadableOptions = []; $checkoutData = $product->getCheckoutData(); $downloadableOptions = $product->getDownloadableLinks(); foreach ($checkoutData['options']['links'] as $link) { $keyLink = str_replace('link_', '', $link['label']); $checkoutDownloadableOptions[] = ['title' => $downloadableOptions['title'], 'value' => $downloadableOptions['downloadable']['link'][$keyLink]['title']]; } $this->data['options'] += $checkoutDownloadableOptions; }
/** * @constructor * @param FixtureInterface $product */ public function __construct(FixtureInterface $product) { parent::__construct($product); /** @var ConfigurableProduct $product */ $checkoutData = $product->getCheckoutData(); $cartItem = isset($checkoutData['cartItem']) ? $checkoutData['cartItem'] : []; $attributesData = $product->getConfigurableOptions()['attributes_data']; $checkoutConfigurableOptions = isset($checkoutData['options']['configurable_options']) ? $checkoutData['options']['configurable_options'] : []; foreach ($checkoutConfigurableOptions as $key => $checkoutConfigurableOption) { $attribute = $checkoutConfigurableOption['title']; $option = $checkoutConfigurableOption['value']; $checkoutConfigurableOptions[$key] = ['title' => isset($attributesData[$attribute]['label']) ? $attributesData[$attribute]['label'] : $attribute, 'value' => isset($attributesData[$attribute]['options'][$option]['label']) ? $attributesData[$attribute]['options'][$option]['label'] : $option]; } $cartItem['options'] = isset($cartItem['options']) ? $cartItem['options'] + $checkoutConfigurableOptions : $checkoutConfigurableOptions; $this->data = array_merge($this->data, $cartItem); }