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 cart edit method. #3045

Closed
sbthemes opened this issue May 23, 2015 · 5 comments
Closed

Problem with cart edit method. #3045

sbthemes opened this issue May 23, 2015 · 5 comments

Comments

@sbthemes
Copy link

Hi,
I was working on project and for that I need custom cart page. SO to update cart item I used cart.update method which is located in common.js file

This function is passing data like this:
Line no 178 in common.js
data: 'key=' + key + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1),

Means it is passing integer or string quantity value.

Now look at controller.

In controller checkout/cart.php file you can find public function edit() { at line no 391
Function is something like this:

public function edit() {
    $this->load->language('checkout/cart');
    $json = array();
    // Update
    if (!empty($this->request->post['quantity'])) {
        foreach ($this->request->post['quantity'] as $key => $value) {
            $this->cart->update($key, $value);
        }

This function assume quantity value as array and running foreach loop. But in common.js update method, it is passing string or integer.

So error generates Invalid argument to supplied to foreach.

So I think in this function need to check if value is array or not.

I am little bit familiar with opencart structure but this is just my second opencart project.

So if I am doing wrong here. Please point me. I am not sure common.js is common or it is based on theme.
Let me know if any questions.

Thanks.

@sbthemes
Copy link
Author

Hey,
I can't see any change on master copy. So am I wrong?

@milimar
Copy link

milimar commented May 24, 2015

The right place to post your issue is here: http://forum.opencart.com

Greetings!

@sbthemes
Copy link
Author

Okay thanks.
Actually I have posted here because I don't need solution. I thought it is bug in open cart. I don't know where to post bug.
By the way thanks.

@milimar
Copy link

milimar commented May 24, 2015

Yes, this is the right place for posting bugs, but your issues is closed because Daniel considers it is not a bug...that's all :)

@sbthemes
Copy link
Author

I am not sure you have checked my explanation or not. This is surely bug. You can try update method and pass quantity as integer and you will get error.

I am using latest version of opencart.

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

3 participants