vuestorefront / vue-storefront-api

Vue.js storefront for Magento2 (and not only) - data backend
https://www.vuestorefront.io
MIT License
348 stars 338 forks source link

Tier prices and tier prices customer groups #554

Open Cheeerd opened 3 years ago

Cheeerd commented 3 years ago

Hello. When I tried to enable tier prices, I faced some problems. In the next list the first 3 items are about vue-storefront-api exactly, and the last 2 are about vue-storefront in general.

  1. Tier prices for "any" customer group (code 32000 in magento) are being ignored. Seems like at this line https://github.com/vuestorefront/vue-storefront-api/blob/1e6236984f9cf5d158ccd3535099d043768b641c/src/helpers/priceTiers.js#L20 condition should also check if tier.customer_group_id === 32000.
  2. Tier prices are being loaded for logged in customer like for not logged in customer. If the product is requested through "api/catalog/vue_storefront_catalog/product/_search", the customer group is taken around this line: https://github.com/vuestorefront/vue-storefront-api/blob/1e6236984f9cf5d158ccd3535099d043768b641c/src/api/catalog.ts#L115 from userToken from requestBody which comes from here: https://github.com/vuestorefront/vue-storefront-api/blob/1e6236984f9cf5d158ccd3535099d043768b641c/src/api/catalog.ts#L58, but the value of this requestBody variable is replaced with elasticsearch query here: https://github.com/vuestorefront/vue-storefront-api/blob/1e6236984f9cf5d158ccd3535099d043768b641c/src/api/catalog.ts#L70, before the userToken or groupId is taken from it. Because of it groupId always is null.
  3. If product is loaded through "/api/url/map", then the passed groupId is always null: https://github.com/vuestorefront/vue-storefront-api/blob/1e6236984f9cf5d158ccd3535099d043768b641c/src/api/url/map.ts#L102
  4. When product page is rendered on server, then there are anyway no customer group id is available, so if you open the app directly from product page in new tab, the tier prices would be shown for not logged in user even if the user is already logged in from current browser.
  5. If alwaysSyncPlatformPricesOver option is enabled, then the prices are being downloaded from magento as for not logged in user, and even if vuestorefront-api calculated tier prices for current user correctly (with some fixes of previous paragraphs), then those prices are being rewritten with prices for not logged in customer.

So I wonder how is it supposed to work, can it work at all (and with which configuration and on which version), and where I might be wrong? Unfortunately, here is written only that I have to enable the options usePriceTiers, and seems like after that all should work right away.