/**
  * {@inheritdoc}
  */
 public function provideVariantsPrices(ProductInterface $product)
 {
     $variantsPrices = [];
     /** @var ProductVariantInterface $variant */
     foreach ($product->getVariants() as $variant) {
         $variantsPrices[] = $this->constructOptionsMap($variant);
     }
     return $variantsPrices;
 }
 function it_provides_array_containing_product_variant_options_map_with_corresponding_price(ProductInterface $tShirt, ProductOptionValueInterface $black, ProductOptionValueInterface $large, ProductOptionValueInterface $small, ProductOptionValueInterface $white, ProductVariantInterface $blackLargeTShirt, ProductVariantInterface $blackSmallTShirt, ProductVariantInterface $whiteLargeTShirt, ProductVariantInterface $whiteSmallTShirt)
 {
     $tShirt->getVariants()->willReturn([$blackSmallTShirt, $whiteSmallTShirt, $blackLargeTShirt, $whiteLargeTShirt]);
     $blackSmallTShirt->getOptionValues()->willReturn([$black, $small]);
     $whiteSmallTShirt->getOptionValues()->willReturn([$white, $small]);
     $blackLargeTShirt->getOptionValues()->willReturn([$black, $large]);
     $whiteLargeTShirt->getOptionValues()->willReturn([$white, $large]);
     $blackSmallTShirt->getPrice()->willReturn(1000);
     $whiteSmallTShirt->getPrice()->willReturn(1500);
     $blackLargeTShirt->getPrice()->willReturn(2000);
     $whiteLargeTShirt->getPrice()->willReturn(2500);
     $black->getOptionCode()->willReturn('t_shirt_color');
     $white->getOptionCode()->willReturn('t_shirt_color');
     $small->getOptionCode()->willReturn('t_shirt_size');
     $large->getOptionCode()->willReturn('t_shirt_size');
     $black->getValue()->willReturn('Black');
     $white->getValue()->willReturn('White');
     $small->getValue()->willReturn('Small');
     $large->getValue()->willReturn('Large');
     $this->provideVariantsPrices($tShirt)->shouldReturn([['t_shirt_color' => 'Black', 't_shirt_size' => 'Small', 'value' => 1000], ['t_shirt_color' => 'White', 't_shirt_size' => 'Small', 'value' => 1500], ['t_shirt_color' => 'Black', 't_shirt_size' => 'Large', 'value' => 2000], ['t_shirt_color' => 'White', 't_shirt_size' => 'Large', 'value' => 2500]]);
 }
Exemplo n.º 3
0
 /**
  * @Given /^(this product) belongs to ("([^"]+)" shipping category)$/
  */
 public function thisProductBelongsToShippingCategory(ProductInterface $product, ShippingCategoryInterface $shippingCategory)
 {
     $product->getVariants()->first()->setShippingCategory($shippingCategory);
     $this->objectManager->flush();
 }
Exemplo n.º 4
0
 /**
  * @Given :numberOfCustomers customers have placed :numberOfOrders orders for total of :total mostly :product product
  * @Given then :numberOfCustomers more customers have placed :numberOfOrders orders for total of :total mostly :product product
  */
 public function customersHavePlacedOrdersForTotalOfMostlyProduct($numberOfCustomers, $numberOfOrders, $total, ProductInterface $product)
 {
     $customers = $this->generateCustomers($numberOfCustomers);
     $sampleProductVariant = $product->getVariants()->first();
     $total = $this->getPriceFromString($total);
     for ($i = 0; $i < $numberOfOrders; $i++) {
         $order = $this->createOrder($customers[rand(0, $numberOfCustomers - 1)], '#' . uniqid(), $product->getChannels()->first());
         $order->setState(OrderInterface::STATE_NEW);
         $this->applyPaymentTransitionOnOrder($order, PaymentTransitions::TRANSITION_COMPLETE);
         $price = $i === $numberOfOrders - 1 ? $total : rand(1, $total);
         $total -= $price;
         $item = $this->orderItemFactory->createNew();
         $item->setVariant($sampleProductVariant);
         $item->setUnitPrice($price);
         $this->itemQuantityModifier->modify($item, 1);
         $order->addItem($item);
         $this->orderRepository->add($order);
     }
 }