コード例 #1
0
 public function testIsValid()
 {
     $product = $this->dummyData->getProduct();
     $catalogPromotion = new CatalogPromotion();
     $catalogPromotion->setCode('20PCTOFF');
     $this->assertTrue($catalogPromotion->isValid(new DateTime(), $product));
 }
コード例 #2
0
 /**
  * @return static
  */
 private function withTag()
 {
     $tag = $this->entity->getTag();
     if ($tag !== null) {
         $this->entityDTO->tag = $this->dtoBuilderFactory->getTagDTOBuilder($tag)->build();
     }
     return $this;
 }
コード例 #3
0
 public function handle(CreateCatalogPromotionCommand $command)
 {
     $catalogPromotion = new CatalogPromotion($command->getCatalogPromotionId());
     $catalogPromotion->setName($command->getName());
     $catalogPromotion->setType(PromotionType::createById($command->getPromotionTypeId()));
     $catalogPromotion->setValue($command->getValue());
     $catalogPromotion->setReducesTaxSubtotal($command->getReducesTaxSubtotal());
     $catalogPromotion->setMaxRedemptions($command->getMaxRedemptions());
     $catalogPromotion->setStart($command->getStartDate());
     $catalogPromotion->setEnd($command->getEndDate());
     if ($command->getTagId() !== null) {
         $tag = $this->tagService->findOneById($command->getTagId());
         $catalogPromotion->setTag($tag);
     }
     $this->catalogPromotionService->create($catalogPromotion);
 }
コード例 #4
0
 public function testGetPriceWithCatalogPromotion()
 {
     $catalogPromotion = new CatalogPromotion();
     $catalogPromotion->setName('20% Off');
     $catalogPromotion->setType(PromotionType::percent());
     $catalogPromotion->setValue(20);
     $this->pricing->setCatalogPromotions([$catalogPromotion]);
     $product = new Product();
     $product->setUnitPrice(1500);
     $expectedPrice = new Price();
     $expectedPrice->unitPrice = 1200;
     $expectedPrice->origUnitPrice = 1500;
     $expectedPrice->addCatalogPromotion($catalogPromotion);
     $expectedPrice->quantityPrice = 1200;
     $expectedPrice->origQuantityPrice = 1500;
     $this->assertEquals($expectedPrice, $this->pricingCalculator->getPrice($product, 1));
 }
コード例 #5
0
ファイル: DummyData.php プロジェクト: inklabs/kommerce-core
 public function getCatalogPromotion()
 {
     $catalogPromotion = new CatalogPromotion();
     $catalogPromotion->setName('Test Catalog Promotion');
     $catalogPromotion->setCode('20PCTOFF');
     $catalogPromotion->setValue(20);
     return $catalogPromotion;
 }