当前位置: 首页>>代码示例>>PHP>>正文


PHP ConfigQuery::checkAvailableStock方法代码示例

本文整理汇总了PHP中Thelia\Model\ConfigQuery::checkAvailableStock方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigQuery::checkAvailableStock方法的具体用法?PHP ConfigQuery::checkAvailableStock怎么用?PHP ConfigQuery::checkAvailableStock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Thelia\Model\ConfigQuery的用法示例。


在下文中一共展示了ConfigQuery::checkAvailableStock方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parseResults

 public function parseResults(LoopResult $loopResult)
 {
     $taxCountry = $this->container->get('thelia.taxEngine')->getDeliveryCountry();
     $locale = $this->request->getSession()->getLang()->getLocale();
     $checkAvailability = ConfigQuery::checkAvailableStock();
     $defaultAvailability = intval(ConfigQuery::read('default-available-stock', 100));
     foreach ($loopResult->getResultDataCollection() as $cartItem) {
         $product = $cartItem->getProduct(null, $locale);
         $productSaleElement = $cartItem->getProductSaleElements();
         $loopResultRow = new LoopResultRow();
         $loopResultRow->set("ITEM_ID", $cartItem->getId());
         $loopResultRow->set("TITLE", $product->getTitle());
         $loopResultRow->set("REF", $product->getRef());
         $loopResultRow->set("QUANTITY", $cartItem->getQuantity());
         $loopResultRow->set("PRODUCT_ID", $product->getId());
         $loopResultRow->set("PRODUCT_URL", $product->getUrl($this->request->getSession()->getLang()->getLocale()));
         if (!$checkAvailability || $product->getVirtual() === 1) {
             $loopResultRow->set("STOCK", $defaultAvailability);
         } else {
             $loopResultRow->set("STOCK", $productSaleElement->getQuantity());
         }
         $loopResultRow->set("PRICE", $cartItem->getPrice())->set("PROMO_PRICE", $cartItem->getPromoPrice())->set("TAXED_PRICE", $cartItem->getTaxedPrice($taxCountry))->set("PROMO_TAXED_PRICE", $cartItem->getTaxedPromoPrice($taxCountry))->set("IS_PROMO", $cartItem->getPromo() === 1 ? 1 : 0);
         $loopResultRow->set("PRODUCT_SALE_ELEMENTS_ID", $productSaleElement->getId());
         $loopResultRow->set("PRODUCT_SALE_ELEMENTS_REF", $productSaleElement->getRef());
         $loopResult->addRow($loopResultRow);
     }
     return $loopResult;
 }
开发者ID:alex63530,项目名称:thelia,代码行数:28,代码来源:Cart.php

示例2: checkStock

 public function checkStock($value, ExecutionContextInterface $context)
 {
     $data = $context->getRoot()->getData();
     if (null === $data["product_sale_elements_id"]) {
         $context->addViolationAt("quantity", Translator::getInstance()->trans("Invalid product_sale_elements"));
     } else {
         $productSaleElements = ProductSaleElementsQuery::create()->filterById($data["product_sale_elements_id"])->filterByProductId($data["product"])->findOne();
         $product = $productSaleElements->getProduct();
         if ($productSaleElements->getQuantity() < $value && $product->getVirtual() === 0 && ConfigQuery::checkAvailableStock()) {
             $context->addViolation(Translator::getInstance()->trans("quantity value is not valid"));
         }
     }
 }
开发者ID:badelas,项目名称:thelia,代码行数:13,代码来源:CartAdd.php

示例3: addQuantity

 public function addQuantity($value)
 {
     $currentQuantity = $this->getQuantity();
     $newQuantity = $currentQuantity + $value;
     if (ConfigQuery::checkAvailableStock()) {
         $productSaleElements = $this->getProductSaleElements();
         $product = $productSaleElements->getProduct();
         if ($product->getVirtual() === 0) {
             if ($productSaleElements->getQuantity() < $newQuantity) {
                 $newQuantity = $currentQuantity;
             }
         }
     }
     $this->setQuantity($newQuantity);
     return $this;
 }
开发者ID:alex63530,项目名称:thelia,代码行数:16,代码来源:CartItem.php

示例4: duplicate

 /**
  * Duplicate the current existing cart. Only the token is changed
  *
  * @param string $token
  * @param Customer $customer
  * @param Currency $currency
  * @param EventDispatcherInterface $dispatcher
  * @return Cart
  * @throws \Exception
  * @throws \Propel\Runtime\Exception\PropelException
  */
 public function duplicate($token, Customer $customer = null, Currency $currency = null, EventDispatcherInterface $dispatcher = null)
 {
     if (!$dispatcher) {
         return false;
     }
     $cartItems = $this->getCartItems();
     $cart = new Cart();
     $cart->setAddressDeliveryId($this->getAddressDeliveryId());
     $cart->setAddressInvoiceId($this->getAddressInvoiceId());
     $cart->setToken($token);
     $discount = 0;
     if (null === $currency) {
         $currencyQuery = CurrencyQuery::create();
         $currency = $currencyQuery->findPk($this->getCurrencyId()) ?: $currencyQuery->findOneByByDefault(1);
     }
     $cart->setCurrency($currency);
     if ($customer) {
         $cart->setCustomer($customer);
         if ($customer->getDiscount() > 0) {
             $discount = $customer->getDiscount();
         }
     }
     $cart->save();
     foreach ($cartItems as $cartItem) {
         $product = $cartItem->getProduct();
         $productSaleElements = $cartItem->getProductSaleElements();
         if ($product && $productSaleElements && $product->getVisible() == 1 && ($productSaleElements->getQuantity() >= $cartItem->getQuantity() || $product->getVirtual() === 1 || !ConfigQuery::checkAvailableStock())) {
             $item = new CartItem();
             $item->setCart($cart);
             $item->setProductId($cartItem->getProductId());
             $item->setQuantity($cartItem->getQuantity());
             $item->setProductSaleElements($productSaleElements);
             $prices = $productSaleElements->getPricesByCurrency($currency, $discount);
             $item->setPrice($prices->getPrice())->setPromoPrice($prices->getPromoPrice())->setPromo($productSaleElements->getPromo());
             $item->save();
             $dispatcher->dispatch(TheliaEvents::CART_ITEM_DUPLICATE, new CartItemDuplicationItem($item, $cartItem));
         }
     }
     try {
         $this->delete();
     } catch (\Exception $e) {
         // just fail silently in some cases
     }
     return $cart;
 }
开发者ID:margery,项目名称:thelia,代码行数:56,代码来源:Cart.php

示例5: pay

 public function pay()
 {
     /* check customer */
     $this->checkAuth();
     /* check cart count */
     $this->checkCartNotEmpty();
     /* check stock not empty */
     if (true === ConfigQuery::checkAvailableStock()) {
         if (null !== ($response = $this->checkStockNotEmpty())) {
             return $response;
         }
     }
     /* check delivery address and module */
     $this->checkValidDelivery();
     /* check invoice address and payment module */
     $this->checkValidInvoice();
     $orderEvent = $this->getOrderEvent();
     $this->getDispatcher()->dispatch(TheliaEvents::ORDER_PAY, $orderEvent);
     $placedOrder = $orderEvent->getPlacedOrder();
     if (null !== $placedOrder && null !== $placedOrder->getId()) {
         /* order has been placed */
         if ($orderEvent->hasResponse()) {
             return $orderEvent->getResponse();
         } else {
             return $this->generateRedirectFromRoute('order.placed', [], ['order_id' => $orderEvent->getPlacedOrder()->getId()]);
         }
     } else {
         /* order has not been placed */
         return $this->generateRedirectFromRoute('cart.view');
     }
 }
开发者ID:margery,项目名称:thelia,代码行数:31,代码来源:OrderController.php

示例6: updateQuantityForCanceledOrder

 /**
  * Update product quantity if new status is canceled or if old status is canceled.
  *
  * @param ModelOrder $order
  * @param $newStatus
  * @param $canceledStatus
  * @throws \Exception
  * @throws \Propel\Runtime\Exception\PropelException
  */
 protected function updateQuantityForCanceledOrder(ModelOrder $order, $newStatus, $canceledStatus)
 {
     $orderProductList = $order->getOrderProducts();
     /** @var OrderProduct  $orderProduct */
     foreach ($orderProductList as $orderProduct) {
         $productSaleElementsId = $orderProduct->getProductSaleElementsId();
         /** @var ProductSaleElements $productSaleElements */
         if (null !== ($productSaleElements = ProductSaleElementsQuery::create()->findPk($productSaleElementsId))) {
             if ($newStatus == $canceledStatus) {
                 $productSaleElements->setQuantity($productSaleElements->getQuantity() + $orderProduct->getQuantity());
             } else {
                 /* check still in stock */
                 if ($orderProduct->getQuantity() > $productSaleElements->getQuantity() && true === ConfigQuery::checkAvailableStock()) {
                     throw new TheliaProcessException($productSaleElements->getRef() . " : Not enough stock");
                 }
                 $productSaleElements->setQuantity($productSaleElements->getQuantity() - $orderProduct->getQuantity());
             }
             $productSaleElements->save();
         }
     }
 }
开发者ID:badelas,项目名称:thelia,代码行数:30,代码来源:Order.php


注:本文中的Thelia\Model\ConfigQuery::checkAvailableStock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。