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

Price and Tax handling / Extend CartProduct / Better totals strategy #12

Open
7 tasks
SamBrishes opened this issue Jan 23, 2024 · 1 comment
Open
7 tasks
Labels
bug Something isn't working feature New feature or request

Comments

@SamBrishes
Copy link

SamBrishes commented Jan 23, 2024

The totals / price values which are added using the CartItemPriceAccessors trait are not "jsonable" at the moment, which becomes problematic when used via Rest-API / headless env.

A hotfix I I'm using is the extension of the CartProduct model using a dynamic method

CartProduct::extend(function (CartProduct $model) {
    $model->append('totals');
    $model->addDynamicMethod('getTotalsAttribute', function () use ($model) {
        return [
            'pre_taxes'             => $model->getTotalPreTaxesAttribute(),
            'taxes'                 => $model->getTotalTaxesAttribute(),
            'post_taxes'            => $model->getTotalPostTaxesAttribute(),
            'weight'                => $model->getTotalWeightAttribute(),
            'product_pre_taxes'     => $model->getProductPreTaxesAttribute(),
            'product_taxes'         => $model->getProductTaxesAttribute(),
            'product_post_taxes'    => $model->getProductPostTaxesAttribute(),
        ];
    });
});

The price handling with / without taxes may should be rethinked in general. The designations are confusing and could lead to incorrect expenditure.

Related issues

@SamBrishes SamBrishes added the feature New feature or request label Jan 23, 2024
@SamBrishes
Copy link
Author

Related issue

OFFLINE-GmbH#12

@SamBrishes SamBrishes added the bug Something isn't working label Jan 23, 2024
@SamBrishes SamBrishes changed the title Extend CartProduct / Better price handling Price and Tax handling / Extend CartProduct / Better totals strategy Jan 23, 2024
@SamBrishes SamBrishes moved this to Ready in Mall NEXT Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feature New feature or request
Projects
Status: Ready
Development

No branches or pull requests

1 participant