Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
samberrry committed Feb 23, 2023
2 parents 6baccc8 + 656f4c0 commit a0be4c5
Show file tree
Hide file tree
Showing 17 changed files with 140 additions and 31 deletions.
4 changes: 4 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ This project is a PrestaShop integration for Vue Storefront 2.
The PrestaShop integration with Vue Storefront is being maintained by [Binshops](https://www.binshops.com).

You can help us to improve the integration by reporting bugs and contributing to the code at the [repository issues page](https://github.com/vuestorefront/prestashop/issues).

## Why Headless?

<iframe width="560" height="315" src="https://www.youtube.com/embed/G1lm1fkraQQ" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
2 changes: 1 addition & 1 deletion packages/api-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue-storefront/prestashop-api",
"version": "1.2.1",
"version": "1.2.2",
"private": false,
"sideEffects": false,
"server": "server/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/composables/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vue-storefront/prestashop",
"version": "1.2.1",
"version": "1.2.2",
"private": false,
"sideEffects": false,
"main": "lib/index.cjs.js",
Expand All @@ -16,7 +16,7 @@
"update:update": "ncu -u"
},
"dependencies": {
"@vue-storefront/prestashop-api": "1.2.1",
"@vue-storefront/prestashop-api": "1.2.2",
"@vue-storefront/core": "~2.7.5"
},
"devDependencies": {
Expand Down
6 changes: 5 additions & 1 deletion packages/composables/src/useBootstrap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ export const useBootstrap = () => {

try {
loading.value = true;
const lang = context.$prestashop.config.app.i18n.locales && context.$prestashop.config.app.i18n.locales.length > 1 ? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';
const lang = context.$prestashop.config.app.i18n.locales &&
context.$prestashop.config.app.i18n.locales.length > 1 &&
context.$prestashop.config.app.$cookies.get('vsf-locale')
? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';

const currency = context.$prestashop.config.app.$cookies.get('vsf-currency');

const { data, cookieObject } = await context.$prestashop.api.bootstrap({ lang: lang, currency: currency });
Expand Down
24 changes: 20 additions & 4 deletions packages/composables/src/useCart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ const params: UseCartFactoryParams<Cart, CartItem, PsProduct> = {
const psCookieKey = context.$prestashop.config.app.$cookies.get(vsfCookieKey);
const psCookieValue = context.$prestashop.config.app.$cookies.get(vsfCookieValue);

const lang = context.$prestashop.config.app.i18n.locales && context.$prestashop.config.app.i18n.locales.length > 1 ? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';
const lang = context.$prestashop.config.app.i18n.locales &&
context.$prestashop.config.app.i18n.locales.length > 1 &&
context.$prestashop.config.app.$cookies.get('vsf-locale')
? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';

const currency = context.$prestashop.config.app.$cookies.get('vsf-currency');
const { data, cookieObject } = await context.$prestashop.api.getCartItems({ psCookieKey, psCookieValue, lang: lang, currency: currency });

Expand All @@ -43,7 +47,11 @@ const params: UseCartFactoryParams<Cart, CartItem, PsProduct> = {
const psCookieKey = context.$prestashop.config.app.$cookies.get(vsfCookieKey);
const psCookieValue = context.$prestashop.config.app.$cookies.get(vsfCookieValue);

const lang = context.$prestashop.config.app.i18n.locales && context.$prestashop.config.app.i18n.locales.length > 1 ? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';
const lang = context.$prestashop.config.app.i18n.locales &&
context.$prestashop.config.app.i18n.locales.length > 1 &&
context.$prestashop.config.app.$cookies.get('vsf-locale')
? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';

const currency = context.$prestashop.config.app.$cookies.get('vsf-currency');

const { data, cookieObject } = await context.$prestashop.api.addToCart({ psCookieKey, psCookieValue, product, quantity, lang: lang, currency: currency });
Expand All @@ -68,7 +76,11 @@ const params: UseCartFactoryParams<Cart, CartItem, PsProduct> = {
const psCookieKey = context.$prestashop.config.app.$cookies.get(vsfCookieKey);
const psCookieValue = context.$prestashop.config.app.$cookies.get(vsfCookieValue);

const lang = context.$prestashop.config.app.i18n.locales && context.$prestashop.config.app.i18n.locales.length > 1 ? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';
const lang = context.$prestashop.config.app.i18n.locales &&
context.$prestashop.config.app.i18n.locales.length > 1 &&
context.$prestashop.config.app.$cookies.get('vsf-locale')
? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';

const currency = context.$prestashop.config.app.$cookies.get('vsf-currency');

const { data, cookieObject } = await context.$prestashop.api.removeFromCart({ psCookieKey, psCookieValue, product, lang: lang, currency: currency });
Expand Down Expand Up @@ -100,7 +112,11 @@ const params: UseCartFactoryParams<Cart, CartItem, PsProduct> = {
const psCookieKey = context.$prestashop.config.app.$cookies.get(vsfCookieKey);
const psCookieValue = context.$prestashop.config.app.$cookies.get(vsfCookieValue);

const lang = context.$prestashop.config.app.i18n.locales && context.$prestashop.config.app.i18n.locales.length > 1 ? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';
const lang = context.$prestashop.config.app.i18n.locales &&
context.$prestashop.config.app.i18n.locales.length > 1 &&
context.$prestashop.config.app.$cookies.get('vsf-locale')
? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';

const currency = context.$prestashop.config.app.$cookies.get('vsf-currency');

const { data, cookieObject } = await context.$prestashop.api.updateCart({ psCookieKey, psCookieValue, product, op, lang: lang, currency: currency });
Expand Down
6 changes: 5 additions & 1 deletion packages/composables/src/useCheckProduct/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export const useCheckProduct = () => {

try {
loading.value = true;
const lang = context.$prestashop.config.app.i18n.locales && context.$prestashop.config.app.i18n.locales.length > 1 ? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';
const lang = context.$prestashop.config.app.i18n.locales &&
context.$prestashop.config.app.i18n.locales.length > 1 &&
context.$prestashop.config.app.$cookies.get('vsf-locale')
? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';

const currency = context.$prestashop.config.app.$cookies.get('vsf-currency');

const data = await context.$prestashop.api.getProduct(
Expand Down
6 changes: 5 additions & 1 deletion packages/composables/src/useCountryList/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ export const useCountryList = () => {

try {
loading.value = true;
const lang = context.$prestashop.config.app.i18n.locales && context.$prestashop.config.app.i18n.locales.length > 1 ? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';
const lang = context.$prestashop.config.app.i18n.locales &&
context.$prestashop.config.app.i18n.locales.length > 1 &&
context.$prestashop.config.app.$cookies.get('vsf-locale')
? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';

const currency = context.$prestashop.config.app.$cookies.get('vsf-currency');

const { data, cookieObject } = await context.$prestashop.api.getAvailableCountries({ lang: lang, currency: currency });
Expand Down
6 changes: 5 additions & 1 deletion packages/composables/src/useFacet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ const factoryParams = {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
search: async (context: Context, params: FacetSearchResult<SearchParams>) => {

const lang = context.$prestashop.config.app.i18n.locales && context.$prestashop.config.app.i18n.locales.length > 1 ? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';
const lang = context.$prestashop.config.app.i18n.locales &&
context.$prestashop.config.app.i18n.locales.length > 1 &&
context.$prestashop.config.app.$cookies.get('vsf-locale')
? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';

const currency = context.$prestashop.config.app.$cookies.get('vsf-currency');

const data = await context.$prestashop.api.getCategoryProducts({ ...params, lang: lang, currency: currency });
Expand Down
6 changes: 5 additions & 1 deletion packages/composables/src/useMakeOrder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ const factoryParams: UseMakeOrderFactoryParams<Order> = {
const psCookieKey = context.$prestashop.config.app.$cookies.get(vsfCookieKey);
const psCookieValue = context.$prestashop.config.app.$cookies.get(vsfCookieValue);

const lang = context.$prestashop.config.app.i18n.locales && context.$prestashop.config.app.i18n.locales.length > 1 ? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';
const lang = context.$prestashop.config.app.i18n.locales &&
context.$prestashop.config.app.i18n.locales.length > 1 &&
context.$prestashop.config.app.$cookies.get('vsf-locale')
? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';

const currency = context.$prestashop.config.app.$cookies.get('vsf-currency');

const { data, cookieObject } = await context.$prestashop.api.makeOrder({ methodName: methodName, psCookieKey, psCookieValue, lang: lang, currency: currency });
Expand Down
6 changes: 5 additions & 1 deletion packages/composables/src/usePayment/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ export const usePayment = () => {
const psCookieKey = context.$prestashop.config.app.$cookies.get(vsfCookieKey);
const psCookieValue = context.$prestashop.config.app.$cookies.get(vsfCookieValue);

const lang = context.$prestashop.config.app.i18n.locales && context.$prestashop.config.app.i18n.locales.length > 1 ? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';
const lang = context.$prestashop.config.app.i18n.locales &&
context.$prestashop.config.app.i18n.locales.length > 1 &&
context.$prestashop.config.app.$cookies.get('vsf-locale')
? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';

const currency = context.$prestashop.config.app.$cookies.get('vsf-currency');

const { data, cookieObject } = await context.$prestashop.api.getPaymentMethods({ psCookieKey, psCookieValue, lang: lang, currency: currency });
Expand Down
6 changes: 5 additions & 1 deletion packages/composables/src/useProduct/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ const params: UseProductFactoryParams<Product, SearchParams> = {
params.variantObj = variantObj;
}

params.lang = context.$prestashop.config.app.i18n.locales && context.$prestashop.config.app.i18n.locales.length > 1 ? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';
params.lang = context.$prestashop.config.app.i18n.locales &&
context.$prestashop.config.app.i18n.locales.length > 1 &&
context.$prestashop.config.app.$cookies.get('vsf-locale')
? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';

params.currency = context.$prestashop.config.app.$cookies.get('vsf-currency');

const data = await context.$prestashop.api.getProduct(params);
Expand Down
12 changes: 10 additions & 2 deletions packages/composables/src/useReview/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ const params: UseReviewFactoryParams<Review, SearchParams, AddParams> = {
searchReviews: async (context: Context, params) => {
const { customQuery, ...searchParams } = params;

const lang = context.$prestashop.config.app.i18n.locales && context.$prestashop.config.app.i18n.locales.length > 1 ? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';
const lang = context.$prestashop.config.app.i18n.locales &&
context.$prestashop.config.app.i18n.locales.length > 1 &&
context.$prestashop.config.app.$cookies.get('vsf-locale')
? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';

const currency = context.$prestashop.config.app.$cookies.get('vsf-currency');

const item = await context.$prestashop.api.getReview({ ...searchParams, lang: lang, currency: currency }, customQuery);
Expand All @@ -32,7 +36,11 @@ const params: UseReviewFactoryParams<Review, SearchParams, AddParams> = {
const key = context.$prestashop.config.app.$cookies.get(cookieKey);
const value = context.$prestashop.config.app.$cookies.get(cookieValue);

const lang = context.$prestashop.config.app.i18n.locales && context.$prestashop.config.app.i18n.locales.length > 1 ? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';
const lang = context.$prestashop.config.app.i18n.locales &&
context.$prestashop.config.app.i18n.locales.length > 1 &&
context.$prestashop.config.app.$cookies.get('vsf-locale')
? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';

const currency = context.$prestashop.config.app.$cookies.get('vsf-currency');

const item = await context.$prestashop.api.addReview({ ...AddParams, customQuery, key, value, lang: lang, currency: currency });
Expand Down
12 changes: 10 additions & 2 deletions packages/composables/src/useShippingProvider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ const params: UseShippingProviderParams<ShippingProvider, ShippingMethod> = {
const psCookieKey = context.$prestashop.config.app.$cookies.get(vsfCookieKey);
const psCookieValue = context.$prestashop.config.app.$cookies.get(vsfCookieValue);

const lang = context.$prestashop.config.app.i18n.locales && context.$prestashop.config.app.i18n.locales.length > 1 ? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';
const lang = context.$prestashop.config.app.i18n.locales &&
context.$prestashop.config.app.i18n.locales.length > 1 &&
context.$prestashop.config.app.$cookies.get('vsf-locale')
? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';

const currency = context.$prestashop.config.app.$cookies.get('vsf-currency');
const { data, cookieObject } = await context.$prestashop.api.getShippingMethods({ psCookieKey, psCookieValue, lang: lang, currency: currency });
if (data.code === 200) {
Expand All @@ -33,7 +37,11 @@ const params: UseShippingProviderParams<ShippingProvider, ShippingMethod> = {
const psCookieKey = context.$prestashop.config.app.$cookies.get(vsfCookieKey);
const psCookieValue = context.$prestashop.config.app.$cookies.get(vsfCookieValue);

const lang = context.$prestashop.config.app.i18n.locales && context.$prestashop.config.app.i18n.locales.length > 1 ? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';
const lang = context.$prestashop.config.app.i18n.locales &&
context.$prestashop.config.app.i18n.locales.length > 1 &&
context.$prestashop.config.app.$cookies.get('vsf-locale')
? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';

const currency = context.$prestashop.config.app.$cookies.get('vsf-currency');

await context.$prestashop.api.setShippingMethod({ ...params.customQuery, psCookieKey, psCookieValue, lang: lang, currency: currency });
Expand Down
31 changes: 26 additions & 5 deletions packages/composables/src/useUser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ const params: UseUserFactoryParams<User, UpdateParams, RegisterParams> = {
const key = context.$prestashop.config.app.$cookies.get(cookieKey);
const value = context.$prestashop.config.app.$cookies.get(cookieValue);

const lang = context.$prestashop.config.app.i18n.locales && context.$prestashop.config.app.i18n.locales.length > 1 ? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';
// todo: lang detection should be another helper - removing duplicates (and cookie mgmt)
const lang = context.$prestashop.config.app.i18n.locales &&
context.$prestashop.config.app.i18n.locales.length > 1 &&
context.$prestashop.config.app.$cookies.get('vsf-locale')
? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';

const currency = context.$prestashop.config.app.$cookies.get('vsf-currency');

if (key && value) {
Expand Down Expand Up @@ -54,7 +59,11 @@ const params: UseUserFactoryParams<User, UpdateParams, RegisterParams> = {
const psCookieKey = context.$prestashop.config.app.$cookies.get(vsfCookieKey);
const psCookieValue = context.$prestashop.config.app.$cookies.get(vsfCookieValue);

const lang = context.$prestashop.config.app.i18n.locales && context.$prestashop.config.app.i18n.locales.length > 1 ? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';
const lang = context.$prestashop.config.app.i18n.locales &&
context.$prestashop.config.app.i18n.locales.length > 1 &&
context.$prestashop.config.app.$cookies.get('vsf-locale')
? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';

const currency = context.$prestashop.config.app.$cookies.get('vsf-currency');

const { data, cookieObject } = await context.$prestashop.api.updateCustomer({ psCookieKey, psCookieValue, updatedUserData, lang: lang, currency: currency });
Expand Down Expand Up @@ -84,7 +93,11 @@ const params: UseUserFactoryParams<User, UpdateParams, RegisterParams> = {
const psCookieKey = context.$prestashop.config.app.$cookies.get(vsfCookieKey);
const psCookieValue = context.$prestashop.config.app.$cookies.get(vsfCookieValue);

const lang = context.$prestashop.config.app.i18n.locales && context.$prestashop.config.app.i18n.locales.length > 1 ? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';
const lang = context.$prestashop.config.app.i18n.locales &&
context.$prestashop.config.app.i18n.locales.length > 1 &&
context.$prestashop.config.app.$cookies.get('vsf-locale')
? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';

const currency = context.$prestashop.config.app.$cookies.get('vsf-currency');

const {data, cookieObject} = await context.$prestashop.api.register({email, password, firstName, lastName, psCookieKey, psCookieValue, lang: lang, currency: currency});
Expand Down Expand Up @@ -126,7 +139,11 @@ const params: UseUserFactoryParams<User, UpdateParams, RegisterParams> = {
const psCookieKey = context.$prestashop.config.app.$cookies.get(vsfCookieKey);
const psCookieValue = context.$prestashop.config.app.$cookies.get(vsfCookieValue);

const lang = context.$prestashop.config.app.i18n.locales && context.$prestashop.config.app.i18n.locales.length > 1 ? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';
const lang = context.$prestashop.config.app.i18n.locales &&
context.$prestashop.config.app.i18n.locales.length > 1 &&
context.$prestashop.config.app.$cookies.get('vsf-locale')
? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';

const currency = context.$prestashop.config.app.$cookies.get('vsf-currency');

const {data, cookieObject} = await context.$prestashop.api.login({username, password, psCookieKey, psCookieValue, lang: lang, currency });
Expand Down Expand Up @@ -160,7 +177,11 @@ const params: UseUserFactoryParams<User, UpdateParams, RegisterParams> = {
const psCookieKey = context.$prestashop.config.app.$cookies.get(vsfCookieKey);
const psCookieValue = context.$prestashop.config.app.$cookies.get(vsfCookieValue);

const lang = context.$prestashop.config.app.i18n.locales && context.$prestashop.config.app.i18n.locales.length > 1 ? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';
const lang = context.$prestashop.config.app.i18n.locales &&
context.$prestashop.config.app.i18n.locales.length > 1 &&
context.$prestashop.config.app.$cookies.get('vsf-locale')
? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';

const currency = context.$prestashop.config.app.$cookies.get('vsf-currency');

const { data, cookieObject } = await context.$prestashop.api.updateCustomer({ psCookieKey, psCookieValue, updatedUserData, lang: lang, currency: currency });
Expand Down
6 changes: 5 additions & 1 deletion packages/composables/src/useUserOrder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ const params: UseUserOrderFactoryParams<Order, SearchParams> = {
const psCookieKey = context.$prestashop.config.app.$cookies.get(vsfCookieKey);
const psCookieValue = context.$prestashop.config.app.$cookies.get(vsfCookieValue);

const lang = context.$prestashop.config.app.i18n.locales && context.$prestashop.config.app.i18n.locales.length > 1 ? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';
const lang = context.$prestashop.config.app.i18n.locales &&
context.$prestashop.config.app.i18n.locales.length > 1 &&
context.$prestashop.config.app.$cookies.get('vsf-locale')
? '/' + context.$prestashop.config.app.$cookies.get('vsf-locale') : '';

const currency = context.$prestashop.config.app.$cookies.get('vsf-currency');

const { data, cookieObject } = await context.$prestashop.api.fetchOrders({ psCookieKey, psCookieValue, orderId, lang: lang, currency: currency });
Expand Down
Loading

0 comments on commit a0be4c5

Please sign in to comment.