Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
feat(Cart): add product type reference to line item
Browse files Browse the repository at this point in the history
Closes #280
  • Loading branch information
Jens Schulze committed Jan 6, 2017
1 parent e9cc4a7 commit e795540
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/Model/Cart/LineItem.php
Expand Up @@ -15,6 +15,7 @@
use Commercetools\Core\Model\TaxCategory\TaxRate;
use Commercetools\Core\Model\CustomField\CustomFieldObject;
use Commercetools\Core\Model\Common\TaxedItemPrice;
use Commercetools\Core\Model\ProductType\ProductTypeReference;

/**
* @package Commercetools\Core\Model\Cart
Expand Down Expand Up @@ -50,6 +51,8 @@
* @method LineItem setTaxedPrice(TaxedItemPrice $taxedPrice = null)
* @method string getPriceMode()
* @method LineItem setPriceMode(string $priceMode = null)
* @method ProductTypeReference getProductType()
* @method LineItem setProductType(ProductTypeReference $productType = null)
*/
class LineItem extends JsonObject
{
Expand All @@ -76,7 +79,8 @@ public function fieldDefinitions()
'discountedPricePerQuantity' => [
static::TYPE => '\Commercetools\Core\Model\Cart\DiscountedPricePerQuantityCollection'
],
'priceMode' => [static::TYPE => 'string']
'priceMode' => [static::TYPE => 'string'],
'productType' => [static::TYPE => '\Commercetools\Core\Model\ProductType\ProductTypeReference']
];
}

Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/models.yaml
Expand Up @@ -45,6 +45,7 @@ lineItem:
- discountedPricePerQuantity
- totalPrice
- priceMode
- productType

customLineItem:
domain: cart
Expand Down
5 changes: 4 additions & 1 deletion tests/integration/Cart/CartUpdateRequestTest.php
Expand Up @@ -142,7 +142,10 @@ public function testLineItem()
$this->deleteRequest->setVersion($cart->getVersion());

$this->assertSame($product->getId(), $cart->getLineItems()->current()->getProductId());

$this->assertSame(
$product->getProductType()->getId(),
$cart->getLineItems()->current()->getProductType()->getId()
);
$request = CartUpdateRequest::ofIdAndVersion($cart->getId(), $cart->getVersion())
->addAction(
CartChangeLineItemQuantityAction::ofLineItemIdAndQuantity($cart->getLineItems()->current()->getId(), 2)
Expand Down
5 changes: 5 additions & 0 deletions tests/integration/Order/OrderUpdateRequestTest.php
Expand Up @@ -110,6 +110,11 @@ public function testChangeState()
$cartDraft = $this->getCartDraft();
$order = $this->createOrder($cartDraft);

$this->assertSame(
$this->getProduct()->getProductType()->getId(),
$order->getLineItems()->current()->getProductType()->getId()
);

$request = OrderUpdateRequest::ofIdAndVersion($order->getId(), $order->getVersion())
->addAction(OrderChangeOrderStateAction::ofOrderState(OrderState::COMPLETE))
;
Expand Down

0 comments on commit e795540

Please sign in to comment.