1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author @jayS-de <[email protected]> |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Commercetools\Core\Request\Carts\Command; |
7
|
|
|
|
8
|
|
|
use Commercetools\Core\Model\Common\Context; |
9
|
|
|
use Commercetools\Core\Model\TaxCategory\ExternalTaxRateDraft; |
10
|
|
|
use Commercetools\Core\Request\AbstractAction; |
11
|
|
|
use Commercetools\Core\Model\Cart\ExternalLineItemTotalPrice; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @package Commercetools\Core\Request\Carts\Command |
15
|
|
|
* @link https://dev.commercetools.com/http-api-projects-carts.html#set-lineitem-totalprice |
16
|
|
|
* @method string getAction() |
17
|
|
|
* @method CartSetLineItemTotalPriceAction setAction(string $action = null) |
18
|
|
|
* @method ExternalLineItemTotalPrice getExternalTotalPrice() |
19
|
|
|
* @method CartSetLineItemTotalPriceAction setExternalTotalPrice(ExternalLineItemTotalPrice $externalTotalPrice = null) |
20
|
|
|
* @method string getLineItemId() |
21
|
|
|
* @method CartSetLineItemTotalPriceAction setLineItemId(string $lineItemId = null) |
22
|
|
|
*/ |
23
|
|
View Code Duplication |
class CartSetLineItemTotalPriceAction extends AbstractAction |
|
|
|
|
24
|
|
|
{ |
25
|
|
|
public function fieldDefinitions() |
26
|
|
|
{ |
27
|
|
|
return [ |
28
|
|
|
'action' => [static::TYPE => 'string'], |
29
|
|
|
'lineItemId' => [static::TYPE => 'string'], |
30
|
|
|
'externalTotalPrice' => [static::TYPE => '\Commercetools\Core\Model\Cart\ExternalLineItemTotalPrice'], |
31
|
|
|
]; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param array $data |
36
|
|
|
* @param Context|callable $context |
37
|
|
|
*/ |
38
|
|
|
public function __construct(array $data = [], $context = null) |
39
|
|
|
{ |
40
|
|
|
parent::__construct($data, $context); |
41
|
|
|
$this->setAction('setLineItemTotalPrice'); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param $lineItemId |
46
|
|
|
* @param Context|callable $context |
47
|
|
|
* @return CartSetLineItemTotalPriceAction |
48
|
|
|
*/ |
49
|
|
|
public static function ofLineItemId($lineItemId, $context = null) |
50
|
|
|
{ |
51
|
|
|
return static::of($context)->setLineItemId($lineItemId); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.