Exemplo n.º 1
0
 /**
  * Checks if a variant is in any of the user's wishlists
  * and responds with a json object.  
  * Responds whether or not the user is logged in
  * 
  */
 public function added()
 {
     $f3 = \Base::instance();
     $variant_id = $this->inputfilter->clean($f3->get('PARAMS.variant_id'), 'alnum');
     $result = false;
     $identity = $this->getIdentity();
     if (empty($identity->id)) {
         // return a false message
         return $this->outputJson($this->getJsonResponse(array('result' => $result)));
     }
     if ($count = \Shop\Models\Wishlists::hasAddedVariant($variant_id, (string) $identity->id)) {
         $result = true;
     }
     return $this->outputJson($this->getJsonResponse(array('result' => $result)));
 }
Exemplo n.º 2
0
    ?>
                                
                    <form action="./shop/cart/add" method="post">
                        <div id="validation-cart-add" class="validation-message"></div>
                        
                        <div class="buttons">
                            <div class="row">
                                <?php 
    if (!empty($item->variantsInStock()) && count($item->variantsInStock()) > 1) {
        ?>
                                <div class="col-sm-8">
                                    
                                    <select name="variant_id" class="chosen-select select-variant variant_id" data-callback="Shop.selectVariant">
                                        <?php 
        foreach ($variantsInStock as $key => $variant) {
            $wishlist_state = \Shop\Models\Wishlists::hasAddedVariant($variant['id'], (string) $this->auth->getIdentity()->id) ? '0' : '1';
            ?>
                                            <option value="<?php 
            echo $variant['id'];
            ?>
" data-variant='<?php 
            echo htmlspecialchars(json_encode(array('id' => $variant['id'], 'key' => $variant['key'], 'image' => $variant['image'], 'quantity' => $variant['quantity'], 'price' => \Shop\Models\Currency::format($item->price($variant['id'])))));
            ?>
'
                                            	data-wishlist="<?php 
            echo $wishlist_state;
            ?>
"><?php 
            echo $variant['attribute_title'] ? $variant['attribute_title'] : $item->title;
            ?>
 </option>