Пример #1
0
 /**
  * Default Function
  *
  * @access public
  * @param $id products id
  * @param $variants variants
  * @return void
  */
 public function index($id, $variants = NULL)
 {
     if (is_numeric($id)) {
         $product = load_product_library($id);
         //if product is found
         if ($product->is_valid()) {
             if ($variants === NULL) {
                 $variants = $this->input->post('variants');
             } else {
                 $variants = parse_variants_string($variants);
             }
             //quantity
             $quantity = $this->input->post('quantity');
             //add to shopping cart
             $this->shopping_cart->add($id, $variants, $quantity);
         }
     }
     //redirect to shopping cart
     redirect('shopping_cart');
 }
Пример #2
0
 function parse_variants_from_id_string($products_id_string)
 {
     $variants = NULL;
     if (!is_numeric($products_id_string)) {
         $tmp = explode('::', $products_id_string);
         if (isset($tmp[1])) {
             $variants = parse_variants_string($tmp[1]);
         }
     }
     return $variants;
 }