اضافة

نستخدم الفانكشن add للاضافة منتج الى عربة التسوق تستقبل 8 مدخلات

               

             
               
                
                use EasyShoppingCart\Cart;

                include 'vendor/autoload.php';

               // Cart::add($id,$name,$price,$quantity,$shipping,$tax,$discount,$options[])

               Cart::add(10,"product 1",100,2,30,10,5,["size"=>"xl" , "color"=>"red"]);

                            
             
                   
             
            

لكن ال quantity-shipping-tax-discount-options لست مجبر على ادخالهم فى حالة اذا لم تقم بادخال هولاء القيم فان القيم الافتراضية لهم هى

  • quantity=1
  • shipping=0
  • tax=0
  • discount=0
  • options=[]

ال id * هو رقم المنتج الذى يتم التعامل به فى حالة الحذف او التعديل

ال name * اسم المنتج لايهم الاسم بالتحديد لان فقط يتم استخدامه فى حالة العرض

ال price * سعر المنتج للقطعة الواحدة

ال quantity كمية المنتج يتم ادخالها كا رقم

ال shipping قيمة شحن المنتج يتم ادخالها كا رقم

ال tax قيمة ضريبة المنتج يتم ادخالها كا رقم

ال discount قيمة خصم المنتج يتم ادخالها كا رقم

ال options هى عبارة عن مصفوفة لاضافة اختيارات للمنتج مثل الحجم اواللون وغير ذلك على سبيل المثال

               

                
                 $options=[
                    "color"=>"red",
                    "size"=>"xl"
                 ];
                
                      
                
            
               

                
                  
                use EasyShoppingCart\Cart;
                Cart::AddpublicCart($tax,$shipping,$discount)
            // tax  :         الافتراضية صفر
            // shipping :     الافتراضية صفر
            // discount :     الافتراضية صفر

                
                      
                
               

تحديث

نستخدم الفانكشن update لتحديث منتج فى عربة التسوق تستقبل 2 مدخلات هما ال id ومضفوفة بها قيم التعديل على سبيل المثال

               

                
                  
                use EasyShoppingCart\Cart;
                $id=20;
                $data=[
                    "shipping"=>10,
                    "discount"=>3,
                ];
                Cart::update($id,$data);
            

                
                      
                
               

عرض الكل

نستخدم الفانكشن getAll لعرض محتويات عربة التسوق

               

                
                  
                    use EasyShoppingCart\Cart;

                    include 'vendor/autoload.php';

                    $cart_data=Cart::getAll();
                    if(!$cart_data){
                        echo "There are no products ";
                    }else{
                        print_r($cart_data);
                    }
                    
                   
                    // output
                   
                    [
                        "products"=>[
                            "id"        => 10
                            "name"      => "product 1"
                            "price"     => 100
                            "quantity"  => 2
                            "shipping"  => 30
                            "tax"       => 10
                            "discount"  => 5
                            "options"   =>[
                                "size"=>"xl",
                                "color"=>"red"
                            ]  
                            "total_price_product" => 235 //السعر مضاعف لان الكمية اثنان
                        ],
                        "total"=>[
                            "price_cart"        => 100
                            "tax_cart"          => 10
                            "shipping_cart"     => 30
                            "discount_cart"     => 5
                            "total_price_cart"  => 235
                        ]
                    ]

                    

                        
                    
                
                      
                
               

عرض المنتجات فقط

نستخدم الفانكشن getProducts لعرض المنتجات فقط فى عربة التسوق

               

                
                  
                    use EasyShoppingCart\Cart;

                    include 'vendor/autoload.php';

                    $products=Cart::getProducts();

                    
                    if(!$products){
                        echo "There are no products ";
                    }else{
                        print_r($products);
                    }
                    // output
                   
                    [
                        [
                            "id"        => 10
                            "name"      => "product 1"
                            "price"     => 100
                            "quantity"  => 2
                            "shipping"  => 30
                            "tax"       => 10
                            "discount"  => 5
                            "options"   =>[
                                "size"=>"xl",
                                "color"=>"red"
                            ]  
                            "total_price_product" => 235 //السعر مضاعف لان الكمية اثنان
                        ]
                    ]

                    

                        
                    
                
                      
                
               

عرض تفاصيل السعر كاملا

نستخدم الفانكشن getTotal لعرض تفاصيل السعر النهائى فى عربة التسوق

               

                
                  
                    use EasyShoppingCart\Cart;

                    include 'vendor/autoload.php';

                    $total=Cart::getTotal();
                    if(!$total){
                        echo "There are no products ";
                    }else{
                        print_r($total);
                    }
                    
                   
                    // output
                   
                    [
                        [
                            "price_cart"        => 100
                            "tax_cart"          => 10
                            "shipping_cart"     => 30
                            "discount_cart"     => 5
                            "total_price_cart"  => 235
                        ]
                    ]

                    

                        
                    
                
                      
                
               

حذف منتج

نستخدم الفانكشن remove لحذف منتج من عربة التسوق وهى تتطلب ال id الخاص بالمنتج على سبيل المثال

               

                        
                          
                            use EasyShoppingCart\Cart;
        
                            include 'vendor/autoload.php';
        
                            Cart::remove(10);
        
                           
        
                            
        
                                
                            
                        
                              
                        
                       

حذف العربة كاملة

نستخدم الفانكشن unsetCart لحذف عربة التسوق

                    
    
                            
                                
                                use EasyShoppingCart\Cart;
            
                                include 'vendor/autoload.php';
            
                                Cart::unsetCart();