Example #1
0
 /**
  * Validates that the cartitem is configured correctly for adding to cart,
  * including quantity availability checks, quantity increment checks, etc
  * 
  * Throws an exception on fail, otherwise returns $this
  * 
  * @param \Shop\Models\Prefabs\CartItem $cartitem
  */
 public function validateAdd($cartitem)
 {
     // does the product track inventory?
     if (\Dsc\ArrayHelper::get($cartitem->product, 'policies.track_inventory')) {
         // is the quantity available?
         $quantity = \Shop\Models\Variants::quantity($cartitem->variant_id);
         if ($cartitem->quantity > $quantity) {
             throw new \Exception('Quantity selected is unavailable');
         }
     }
     // Fire an event so that any Listeners that want to stop validation
     // can throw an exception
     $event = \Dsc\System::instance()->trigger('onShopValidateAddToCart', array('cart' => $this, 'cartitem' => $cartitem));
     return $this;
 }
Example #2
0
        ?>
                                
                                <div class="price"><?php 
        echo \Shop\Models\Currency::format($product->price());
        ?>
</div>
                                                                
                            </div>                
                        </div>
                    </div>
                </div>
            
                <div class="col-xs-4 col-sm-3 col-md-3">
                    <div class="price text-center">
                    <?php 
        if (\Shop\Models\Variants::quantity(\Dsc\ArrayHelper::get($item, 'variant_id'))) {
            ?>
                        <a class="btn btn-default" data-product-sku="<?php 
            echo \Dsc\ArrayHelper::get($item, 'sku');
            ?>
" data-product-variant="<?php 
            echo \Dsc\ArrayHelper::get($item, 'attribute_title');
            ?>
" data-product-name="<?php 
            echo \Dsc\ArrayHelper::get($item, 'product.title');
            ?>
" href="./shop/wishlist/<?php 
            echo $wishlist->id;
            ?>
/cart/<?php 
            echo \Dsc\ArrayHelper::get($item, 'hash');