getSellPrice() 공개 메소드

public getSellPrice ( ) : DiscountablePrice
리턴 WellCommerce\Bundle\AppBundle\Entity\DiscountablePrice
예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function calculateProduct(ShippingMethodInterface $shippingMethod, ProductInterface $product)
 {
     $baseCurrency = $product->getSellPrice()->getCurrency();
     $targetCurrency = $shippingMethod->getCurrency()->getCode();
     $totalGrossAmount = $this->currencyHelper->convert($product->getSellPrice()->getFinalGrossAmount(), $baseCurrency, $targetCurrency);
     $ranges = $shippingMethod->getCosts();
     $supportedRanges = $ranges->filter(function (ShippingMethodCostInterface $cost) use($totalGrossAmount) {
         return $cost->getRangeFrom() <= $totalGrossAmount && $cost->getRangeTo() >= $totalGrossAmount;
     });
     if ($supportedRanges->count()) {
         return $supportedRanges->first();
     }
     return null;
 }
 /**
  * Recalculates sell prices for product
  *
  * @param ProductInterface $product
  */
 protected function refreshProductSellPrices(ProductInterface $product)
 {
     $sellPrice = $product->getSellPrice();
     $grossAmount = $sellPrice->getGrossAmount();
     $discountedGrossAmount = $sellPrice->getDiscountedGrossAmount();
     $taxRate = $product->getSellPriceTax()->getValue();
     $netAmount = TaxHelper::calculateNetPrice($grossAmount, $taxRate);
     $discountedNetAmount = TaxHelper::calculateNetPrice($discountedGrossAmount, $taxRate);
     $sellPrice->setTaxRate($taxRate);
     $sellPrice->setTaxAmount($grossAmount - $netAmount);
     $sellPrice->setNetAmount($netAmount);
     $sellPrice->setDiscountedTaxAmount($discountedGrossAmount - $discountedNetAmount);
     $sellPrice->setDiscountedNetAmount($discountedNetAmount);
 }
 public function getCurrency() : string
 {
     return $this->product->getSellPrice()->getCurrency();
 }
 protected function syncProductStock(ProductInterface $product)
 {
     $trackStock = $product->getTrackStock();
     $stock = $product->getStock();
     $grossPrice = $product->getSellPrice()->getFinalGrossAmount();
     $isStockAvailable = true === $trackStock ? $stock > 0 : 1;
     $isPriceNonZero = $grossPrice > 0;
     if (false === $isStockAvailable && false === $isPriceNonZero) {
         $product->setEnabled(false);
     }
 }