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 component #362

Draft
wants to merge 31 commits into
base: master
Choose a base branch
from
Draft

Price component #362

wants to merge 31 commits into from

Conversation

royduin
Copy link
Member

@royduin royduin commented Oct 18, 2023

Breaking:

  • Customer token has been removed from localstorage. All references to the customer token in this way should be replaced with:
import { token } from 'Vendor/rapidez/core/resources/js/stores/useUser'
token.value

if (['shipping', 'billing'].includes(window.config?.tax?.calculation.based_on)) {
country_id = window.app?.$data?.checkout?.[window.config?.tax?.calculation.based_on + '_address']?.country_id || country_id
region_id = window.app?.$data?.checkout?.[window.config?.tax?.calculation.based_on + '_address']?.region_id || region_id
postcode = window.app?.$data?.checkout?.[window.config?.tax?.calculation.based_on + '_address']?.postcode || postcode
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let basedOn = window.app?.$data?.checkout?.[window.config?.tax?.calculation.based_on + '_address']

And then use that instead of repeating it 3 times, would probably be much cleaner here.

->where(fn ($query) => $query
->where('all_groups', 1)
->orWhere('customer_group_id', auth('magento-customer')->user()?->group_id ?? 0)
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting?


price() {
return this.calculatePrice(this.options)
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be thought out again, Magento doesn't work with prices this way.

Prices are calculated as follows: Final Price=Min(Regular(Base) Price, Group(Tier) Price, Special Price, Catalog Price Rule) + Sum(Min Price per each required custom option)

Note that prices are clamped to a minimum of 0 before and after the custom options are added. Also, the price gets rounded before getting multiplied by the qty.

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

Successfully merging this pull request may close these issues.

3 participants