示例#1
0
文件: Product.php 项目: janusnic/shop
 public function scopeIsVisible($query)
 {
     // Selects products that are visible from a category page
     $query->where('is_visible', TRUE)->isActive();
     // Check the settings and see if out of stock products should be hidden
     if (Settings::get('show_oos_products') == 0) {
         $query->whereHas('inventories', function ($inventory) {
             $inventory->inStock();
         });
     }
 }
示例#2
0
 public function scopeIsVisible($query)
 {
     // Returns categories visible in the categories list
     $query->where('is_active', TRUE)->where('is_visible', TRUE);
     if (!Settings::get('show_empty_categories')) {
         $query->whereHas('products', function ($product) {
             if (!Settings::get('show_oos_products')) {
                 $product->inStock();
             }
         });
         if (Product::isDiscounted()->isVisible()->count() > 0) {
             $query->orWhere('pseudo', 'sale');
         }
     }
 }
示例#3
0
 /**
  * Refresh the cart cookie
  */
 private function refreshCartCookie()
 {
     if ($this->cart) {
         Cookie::queue('bedard_shop_cart', ['id' => $this->cart->id, 'key' => $this->cart->key], Settings::get('cart_life'));
     }
 }
示例#4
0
文件: Product.php 项目: janusnic/shop
 /**
  * Product
  */
 public function onRun()
 {
     // Load the product
     $product = ProductModel::where('slug', $this->property('slug'))->with('discounts')->with('categories.discounts')->with('inventories')->with('images')->isActive()->first();
     // Check if the product was found
     $this->exists = (bool) $product;
     if (!$this->exists) {
         return;
     }
     // Load product variables
     $this->name = $product->name;
     $this->slug = $product->slug;
     $this->description = $product->description;
     $this->price = $product->price;
     $this->fullPrice = $product->fullPrice;
     $this->isDiscounted = $product->isDiscounted;
     $this->discount = $product->discount;
     $this->images = $product->images;
     $this->inStock = $product->inStock;
     // Check if the product has multiple inventories
     $this->hasMultipleInventories = count($product->inventories) > 1;
     // Load the inventories into their container
     foreach ($product->inventories as $inventory) {
         if (Settings::get('show_oos_inventories') || $inventory->quantity > 0) {
             $this->inventories[] = $inventory;
         }
     }
 }