Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with PHP 7.4 #39

Open
maiskiykot opened this issue Sep 13, 2024 · 3 comments
Open

Problem with PHP 7.4 #39

maiskiykot opened this issue Sep 13, 2024 · 3 comments

Comments

@maiskiykot
Copy link

maiskiykot commented Sep 13, 2024

Hello!
I have error "Too few arguments to function OfflineAgency\LaravelCart\Cart::add(), 1 passed in..." after migration to PHP 7.4. All arguments transfers to function add(). How I can fix it?

@ManuelRomanato
Copy link
Contributor

Hi @maiskiykot,

Can you show us the snippet where you call the add method?

@maiskiykot
Copy link
Author

maiskiykot commented Sep 13, 2024

use OfflineAgency\LaravelCart\Cart;

class CartController...

public function addcart(Request $request, $id){
$item_data=Item::where("id",$id)->with('ingredients')->first();
if (isset($request->half))
$request->qty = 0.5;

    $ingredients = []; 
   if (!empty($request->interdient)) {
     foreach($item_data->ingredients as $value) {
       
      if (in_array($value->id,$request->interdient) OR $value->type == 0) {
          
        $ingredients[] = [$value->item_name => (int)$request->qty*$value->price];
       }  
     }
   }
      //dd($id);    
  
    \Cart::add(array(     
'id' => $item_data->id, //unique row ID
'name' => $item_data->menu_name,
'qty' => $request->qty,
'price' => $item_data->price,
'subtitle' => $item_data->halfprice,
'totalPrice' => '',
'vatFcCode' => '',
'productFcCode' => '',
'urlImg' => '',
'vat' => null
  ));
  Session::flash('message', __('messages.item_success')); 
  Session::flash('alert-class', 'alert-success');
   return redirect()->back();
}

@maiskiykot
Copy link
Author

maiskiykot commented Sep 13, 2024

It works if PHP 7.2

I corrrected your class Cart

public function add( $id, $name = null, $subtitle = null, $qty = null, $price = null, $totalPrice = null, $vatFcCode = null, $productFcCode = null, $vat = null, $urlImg = null, $options = []

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants