getSellPrice() public method

public getSellPrice ( ) : DiscountablePrice
return 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;
 }
コード例 #2
0
 /**
  * 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);
 }
コード例 #3
0
 public function getCurrency() : string
 {
     return $this->product->getSellPrice()->getCurrency();
 }
コード例 #4
0
 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);
     }
 }