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 Nov 3, 2022
2 parents 5a2f449 + ee08fb7 commit d1fe22b
Show file tree
Hide file tree
Showing 72 changed files with 2,147 additions and 187 deletions.
3 changes: 3 additions & 0 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ module.exports = {
children: [
['/', 'Introduction'],
['/guide/getting-started', 'Getting started'],
['/guide/payment-options', 'Payment Basics'],
['/guide/multi-language', 'Multi Language'],
['/guide/about', 'About'],
]
},
Expand All @@ -85,6 +87,7 @@ module.exports = {
collapsable: true,
children: [
['/guide/releases/v1.0.0', 'v1.0.0'],
['/guide/releases/v1.1.0', 'v1.1.0'],
]
}
]
Expand Down
21 changes: 21 additions & 0 deletions docs/guide/multi-language.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Multi Language
Multi-language support added in version 1.1.0. The PrestaShop integration supports single language by default. However, to support multi-language we need to do some configurations.

## How to enable multi-lang support?
To get multi-language support working properly, we need to enable the desired languages on both PrestaShop BO and VSF integration (within nuxt configuration). To enable your desired languages in front side, first locate the `packages/theme/nuxt.config.js` file and then try to add your language in `i18n.locales` section.

## Multi-currency
Once you have added languages, you can bind each language to a currency. You can do this in the nuxt configurations through `numberFormats`. Locate the `packages/theme/nuxt.config.js` file and try to add language currency settings in `numberFormats`. This way, when user tries to change language the currency will be changed based on these settings. If you see this is a limitation, you can disable it and customize it yourself. To do it, set `autoChangeCookie.currency` to `false` .

For more info about Vue Storefront localization you can take a look at [this link](https://docs.vuestorefront.io/v2/getting-started/internationalization.html#currency-detection).

## List of supported languages
- English (default)
- German
- French
- Italian
- Spanish
- Portuguese

## Contribute to add a new language
Language files are located at `packages/theme/lang` directory, you can make a copy of `en.js` and then rename it and then try to translate the value part of the translation file.
18 changes: 18 additions & 0 deletions docs/guide/payment-options.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Payment Basics

## How to implement payment options?
Normally, PSPs (Payment Service Providers)/Payment gateways, provide payment services in three ways:
- Payment Links: through which you embed or share a link without a website
- Redirect: take your customers to the gateway pages
- SDKs: Integrate customizable UI components into our website

Here I just cover the redirect method, because most of the current PrestaShop modules already support this method, therefore it would be easier to implement.

## Redirect Method
![An image](./../img/vsf-redirect-payment.png)

1. Customer clicks on Place Order in payment page. The request will be sent to the middlewre server (normally this happens when user clicks on something, like when user clicks on product detail page).
2. Middleware logic (in app-client) calls our eCommerce API (PrestaShop) to get a redirect link to the payment gateway. Probably, we need to pass callback/redirect back link to our website (which is a middleware API). In other words, this step is not just to get redirect link, in this step we get any data required for going to payment gateway, it could be a token, and it could be a generated redirect link to payment gateway.
3. User will be redirected to payment gateway page.
4. Gateway will call our callback url (our old PrestaShop module front controller).
5. The payment module determines whether to redirect the user to a success page or a failure page.
14 changes: 14 additions & 0 deletions docs/guide/releases/v1.1.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## v1.1.0 Release
Major feature which is added in this release is multi-language support. To read more about this feature let's take a look at the Multi Language section of this documentation.

## Features
- [Feature] Multi-language support (samberrry, noori1995)
- [Feature] Added four new translations ES,PT,FR,IT (alexescuer)
- [Feature] Multi-currency support (samberrry, noori1995)

## Fixes
- [Fix] Cart total price - Issue [#37](https://github.com/vuestorefront-community/prestashop/issues/37)
- [Fix] Menus are not closing on mobile Issue [#32](https://github.com/vuestorefront-community/prestashop/issues/32)
- [Fix] Menu items disappear after clicking on one Issue [#58](https://github.com/vuestorefront-community/prestashop/issues/58)
- [Fix] In registration, VSF does not show errors when an email already exists [#52](https://github.com/vuestorefront-community/prestashop/issues/52)

Binary file added docs/img/vsf-redirect-payment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.0.1",
"version": "1.1.0",
"private": false,
"sideEffects": false,
"server": "server/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/api-client/src/api/addNewAddress/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { cookieParser } from '../../helpers/cookieParser';
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default async function addNewAddress(context, params) {
const { address } = params;
const url = new URL(context.config.api.url + '/rest/address');

const url = new URL(context.config.api.url + params.lang + '/rest/address');
url.searchParams.set('iso_currency', params.currency);
const { data, headers } = await context.client.post(url.href, address, {
headers: {
Cookie: params.psCookieKey + '=' + params.psCookieValue + ';'
Expand Down
4 changes: 2 additions & 2 deletions packages/api-client/src/api/addReview/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default async function addReview(context, params) {
const url = new URL(context.config.api.url + '/rest/postcomment');

const url = new URL(context.config.api.url + params.lang + '/rest/postcomment');
url.searchParams.set('iso_currency', params.currency);
// eslint-disable-next-line camelcase
const { id_product, comment_title, comment_content, criterion, key, value } = params;
const { data } = await context.client.post(url.href, {
Expand Down
4 changes: 2 additions & 2 deletions packages/api-client/src/api/addToCart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {cookieParser} from '../../helpers/cookieParser';
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default async function addToCart(context, params) {
const {psCookieKey, psCookieValue, product, quantity} = params;
const url = new URL(context.config.api.url + '/rest/cart');

const url = new URL(context.config.api.url + params.lang + '/rest/cart');
url.searchParams.set('iso_currency', params.currency);
url.searchParams.set('id_product', product.id);
url.searchParams.set('qty', quantity);
url.searchParams.set('id_product_attribute', product.attributeId);
Expand Down
6 changes: 3 additions & 3 deletions packages/api-client/src/api/bootstrap/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {cookieParser} from '../../helpers/cookieParser';

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default async function bootstrap(context) {
const url = new URL(context.config.api.url + '/rest/lightbootstrap');
export default async function bootstrap(context, params) {
const url = new URL(context.config.api.url + params.lang + '/rest/lightbootstrap');

url.searchParams.set('menu_with_images', 'single');

url.searchParams.set('iso_currency', params.currency);
const { data, headers } = await context.client.get(url.href);
const cookieObject = cookieParser(headers);

Expand Down
4 changes: 2 additions & 2 deletions packages/api-client/src/api/fetchOrders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { cookieParser } from '../../helpers/cookieParser';
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default async function fetchOrders(context, params) {
const {psCookieKey, psCookieValue, orderId} = params;
const url = new URL(context.config.api.url + '/rest/orderhistory');

const url = new URL(context.config.api.url + params.lang + '/rest/orderhistory');
url.searchParams.set('iso_currency', params.currency);
if (orderId) {
url.searchParams.set('id_order', orderId);
}
Expand Down
6 changes: 3 additions & 3 deletions packages/api-client/src/api/getAvailableCountries/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { cookieParser } from '../../helpers/cookieParser';

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default async function getAvailableCountries(context) {

const url = new URL(context.config.api.url + '/rest/addressform');
export default async function getAvailableCountries(context, params) {

const url = new URL(context.config.api.url + params.lang + '/rest/addressform');
url.searchParams.set('iso_currency', params.currency);
const { data, headers } = await context.client.get(url.href);
const cookieObject = cookieParser(headers);

Expand Down
4 changes: 2 additions & 2 deletions packages/api-client/src/api/getCartItems/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { cookieParser } from '../../helpers/cookieParser';
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default async function getCartItems(context, params) {
const {psCookieKey, psCookieValue} = params;
const url = new URL(context.config.api.url + '/rest/cart');

const url = new URL(context.config.api.url + params.lang + '/rest/cart');
url.searchParams.set('iso_currency', params.currency);
url.searchParams.set('image_size', 'medium_default');

if (psCookieKey && psCookieValue) {
Expand Down
8 changes: 4 additions & 4 deletions packages/api-client/src/api/getCategoryProducts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import {facetParams} from '../../helpers/facetParams';
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default async function getCategoryProducts(context, params) {
if (params.input.type && params.input.type === 'instant-search') {
const url = new URL(context.config.api.url + '/rest/productSearch');

const url = new URL(context.config.api.url + params.lang + '/rest/productSearch');
url.searchParams.set('iso_currency', params.currency);
url.searchParams.set('s', params.input.term);

const { data } = await context.client.get(url.href);
return data;
} else {
const url = new URL(context.config.api.url + '/rest/categoryProducts');

const url = new URL(context.config.api.url + params.lang + '/rest/categoryProducts');
url.searchParams.set('iso_currency', params.currency);
const facetsUrl = facetParams(params.input.filters);

url.searchParams.set('slug', params.input.categorySlug);
Expand Down
4 changes: 2 additions & 2 deletions packages/api-client/src/api/getPaymentMethods/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { cookieParser } from '../../helpers/cookieParser';

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default async function getPaymentMethods(context, params) {
const url = new URL(context.config.api.url + '/rest/paymentoptions');

const url = new URL(context.config.api.url + params.lang + '/rest/paymentoptions');
url.searchParams.set('iso_currency', params.currency);
const { data, headers } = await context.client.get(url.href, {
headers: {
Cookie: params.psCookieKey + '=' + params.psCookieValue + ';'
Expand Down
6 changes: 3 additions & 3 deletions packages/api-client/src/api/getProduct/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default async function getProduct(context, params) {
if (params.id) {
const url = new URL(context.config.api.url + '/rest/productdetail');
const url = new URL(context.config.api.url + params.lang + '/rest/productdetail');
url.searchParams.set('iso_currency', params.currency);
params.id && url.searchParams.set('product_id', params.id);
if (params.refresh) {
params.refresh && url.searchParams.set('refresh', params.refresh);
Expand All @@ -12,8 +13,7 @@ export default async function getProduct(context, params) {
const { data } = await context.client.get(url.href);
return data;
} else if (params.featured) {
const url = new URL(context.config.api.url + '/rest/featuredproducts');

const url = new URL(context.config.api.url + params.lang + '/rest/featuredproducts');
const { data } = await context.client.get(url.href);
return data;
}
Expand Down
5 changes: 3 additions & 2 deletions packages/api-client/src/api/getReview/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default async function getReview(context, params) {
const url = new URL(context.config.api.url + '/rest/listcomments');
const url = new URL(context.config.api.url + params.lang + '/rest/listcomments');
url.searchParams.set('iso_currency', params.currency);
params.productId && url.searchParams.set('id_product', params.productId);
params.productId && url.searchParams.set('page', params.page);
params.page && url.searchParams.set('page', params.page);

const { data } = await context.client.get(url.href);
return data;
Expand Down
4 changes: 2 additions & 2 deletions packages/api-client/src/api/getShippingMethods/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { cookieParser } from '../../helpers/cookieParser';

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default async function getShippingMethods(context, params) {
const url = new URL(context.config.api.url + '/rest/carriers');

const url = new URL(context.config.api.url + params.lang + '/rest/carriers');
url.searchParams.set('iso_currency', params.currency);
const { data, headers } = await context.client.get(url.href, {
headers: {
Cookie: params.psCookieKey + '=' + params.psCookieValue + ';'
Expand Down
4 changes: 2 additions & 2 deletions packages/api-client/src/api/loadAddresses/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { cookieParser } from '../../helpers/cookieParser';

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default async function loadAddresses(context, params) {
const url = new URL(context.config.api.url + '/rest/alladdresses');

const url = new URL(context.config.api.url + params.lang + '/rest/alladdresses');
url.searchParams.set('iso_currency', params.currency);
const { data, headers } = await context.client.get(url.href, {
headers: {
Cookie: params.psCookieKey + '=' + params.psCookieValue + ';'
Expand Down
4 changes: 2 additions & 2 deletions packages/api-client/src/api/loadCustomer/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default async function loadCustomer(context, params) {
const url = new URL(context.config.api.url + '/rest/accountInfo');

const url = new URL(context.config.api.url + params.lang + '/rest/accountInfo');
url.searchParams.set('iso_currency', params.currency);
const { data } = await context.client.get(url.href, {
headers: {
Cookie: params.key + '=' + params.value + ';'
Expand Down
3 changes: 2 additions & 1 deletion packages/api-client/src/api/login/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import {cookieParser} from '../../helpers/cookieParser';

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default async function login(context, params) {
const url = new URL(context.config.api.url + '/rest/login');
const url = new URL(context.config.api.url + params.lang + '/rest/login');
url.searchParams.set('iso_currency', params.currency);
const { username, password, psCookieKey, psCookieValue } = params;

const { data, headers } = await context.client.post(url.href, {
Expand Down
4 changes: 2 additions & 2 deletions packages/api-client/src/api/makeOrder/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { cookieParser } from '../../helpers/cookieParser';
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default async function makeOrder(context, params) {
const { methodName } = params;
const url = new URL(context.config.api.url + `/rest/${methodName}`);

const url = new URL(context.config.api.url + params.lang + `/rest/${methodName}`);
url.searchParams.set('iso_currency', params.currency);
const { data, headers } = await context.client.get(url.href, {
headers: {
Cookie: params.psCookieKey + '=' + params.psCookieValue + ';'
Expand Down
3 changes: 2 additions & 1 deletion packages/api-client/src/api/register/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import {cookieParser} from '../../helpers/cookieParser';

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default async function register(context, params) {
const url = new URL(context.config.api.url + '/rest/register');
const url = new URL(context.config.api.url + params.lang + '/rest/register');
url.searchParams.set('iso_currency', params.currency);
const { email, password, firstName, lastName, psCookieKey, psCookieValue } = params;

const { data, headers } = await context.client.post(url.href, {
Expand Down
3 changes: 2 additions & 1 deletion packages/api-client/src/api/removeAddress/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { cookieParser } from '../../helpers/cookieParser';
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default async function removeAddress(context, params) {
const { id } = params;
const url = new URL(context.config.api.url + '/rest/address');
const url = new URL(context.config.api.url + params.lang + '/rest/address');
url.searchParams.set('iso_currency', params.currency);
// eslint-disable-next-line camelcase
const { data, headers } = await context.client.delete(url.href, {
headers: {
Expand Down
3 changes: 2 additions & 1 deletion packages/api-client/src/api/removeFromCart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {cookieParser} from '../../helpers/cookieParser';
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default async function removeFromCart(context, params) {
const {psCookieKey, psCookieValue, product} = params;
const url = new URL(context.config.api.url + '/rest/cart');
const url = new URL(context.config.api.url + params.lang + '/rest/cart');
url.searchParams.set('iso_currency', params.currency);

url.searchParams.set('id_product', product.id);
url.searchParams.set('id_product_attribute', product.productAttributeId);
Expand Down
4 changes: 2 additions & 2 deletions packages/api-client/src/api/setAddress/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export default async function setAddress(context, params) {
const { id } = params;
// eslint-disable-next-line camelcase
const body = { id_address: id };
const url = new URL(context.config.api.url + '/rest/setaddresscheckout');

const url = new URL(context.config.api.url + params.lang + '/rest/setaddresscheckout');
url.searchParams.set('iso_currency', params.currency);
const { data, headers } = await context.client.post(url.href, body, {
headers: {
Cookie: params.psCookieKey + '=' + params.psCookieValue + ';'
Expand Down
4 changes: 2 additions & 2 deletions packages/api-client/src/api/setShippingMethod/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export default async function setShippingMethod(context, params) {
const { shippingMethodId, addressId } = params;
// eslint-disable-next-line camelcase
const body = { id_address: addressId, id_carrier: shippingMethodId };
const url = new URL(context.config.api.url + '/rest/setcarriercheckout');

const url = new URL(context.config.api.url + params.lang + '/rest/setcarriercheckout');
url.searchParams.set('iso_currency', params.currency);
const { data, headers } = await context.client.post(url.href, body, {
headers: {
Cookie: params.psCookieKey + '=' + params.psCookieValue + ';'
Expand Down
4 changes: 2 additions & 2 deletions packages/api-client/src/api/updateCart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { cookieParser } from '../../helpers/cookieParser';
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default async function updateCart(context, params) {
const {psCookieKey, psCookieValue, product, op} = params;
const url = new URL(context.config.api.url + '/rest/cart');

const url = new URL(context.config.api.url + params.lang + '/rest/cart');
url.searchParams.set('iso_currency', params.currency);
url.searchParams.set('id_product', product.id);
url.searchParams.set('id_product_attribute', product.productAttributeId);
url.searchParams.set('qty', '1');
Expand Down
3 changes: 2 additions & 1 deletion packages/api-client/src/api/updateCustomer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { cookieParser } from '../../helpers/cookieParser';
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default async function updateCustomer(context, params) {
const { updatedUserData } = params;
const url = new URL(context.config.api.url + '/rest/accountedit');
const url = new URL(context.config.api.url + params.lang + '/rest/accountedit');
url.searchParams.set('iso_currency', params.currency);
const { data, headers } = await context.client.post(url.href, updatedUserData, {
headers: {
Cookie: params.psCookieKey + '=' + params.psCookieValue + ';'
Expand Down
4 changes: 2 additions & 2 deletions packages/api-client/src/api/updateOneAddress/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { cookieParser } from '../../helpers/cookieParser';
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default async function updateOneAddress(context, params) {
const { address } = params;
const url = new URL(context.config.api.url + '/rest/address');

const url = new URL(context.config.api.url + params.lang + '/rest/address');
url.searchParams.set('iso_currency', params.currency);
const { data, headers } = await context.client.post(url.href, address, {
headers: {
Cookie: params.psCookieKey + '=' + params.psCookieValue + ';'
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.0.1",
"version": "1.1.0",
"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.0.1",
"@vue-storefront/prestashop-api": "1.1.0",
"@vue-storefront/core": "~2.5.4"
},
"devDependencies": {
Expand Down
Loading

0 comments on commit d1fe22b

Please sign in to comment.