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

change item quantity with priced addon #663

Open
Malebestia opened this issue Nov 30, 2021 · 0 comments
Open

change item quantity with priced addon #663

Malebestia opened this issue Nov 30, 2021 · 0 comments

Comments

@Malebestia
Copy link

if, in the cart, I change the quantity of an item that has an addon, the single price is not updated correctly because the price of the addon is not considered in the calculation. Have you already thought about it?

I suggest these changes: in CartiItem.php:

`public function __get($attribute) {
    //......
    if ('totalPriceAddons' == $attribute) {
        if (! $this->options->has('addons')) {
            return 0;
        }
    //.....
    if ('total' === $attribute) {
        return $this->qty * ($this->priceTax + $this->totalPriceAddons);
    }
}`

in Cart.php:

`public function total($decimals = null, $decimalPoint = null, $thousandSeperator = null) {
    $content = $this->getContent();
    $total = $content->reduce(function ($total, CartItem $cartItem) {
        //return $total + ($cartItem->qty * $cartItem->priceTax);
        return $total + ($cartItem->total);
    }, 0);
    return $this->numberFormat($total, $decimals, $decimalPoint, $thousandSeperator);
}`
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

1 participant