From 0667ef9f9f667c27a6760d31e501259b07f8af95 Mon Sep 17 00:00:00 2001 From: dm-heinze Date: Fri, 30 Jun 2023 13:00:47 +0200 Subject: [PATCH 01/65] issue#148 replaced usaged of environment variables: APP_BASE_URL, SW_PAYMENT_FINISH_URL, SW_PAYMENT_ERROR_URL with useRequestURL().origin (#149) --- docs/pwa/architecture/shop-connection.md | 6 ------ docs/pwa/what/installation.md | 6 ------ docs/pwa/what/overview.md | 6 ------ src/platforms/shopware/composables/useCheckout.ts | 7 +++---- src/platforms/shopware/composables/usePage.ts | 7 +++---- src/platforms/shopware/config/.env_example | 6 ------ src/platforms/shopware/config/config.ts | 5 +---- 7 files changed, 7 insertions(+), 36 deletions(-) diff --git a/docs/pwa/architecture/shop-connection.md b/docs/pwa/architecture/shop-connection.md index 8eebf5ac..67958e15 100644 --- a/docs/pwa/architecture/shop-connection.md +++ b/docs/pwa/architecture/shop-connection.md @@ -10,18 +10,12 @@ For all available configs take a look in the Shopware 6 example .env: ``` -APP_BASE_URL = 'http://localhost:3000' - PLATFORM = 'shopware' PLATFORM_BASE_URL = 'http://my-shopware' API_BASE_URL = 'http://my-shopware/store-api' API_SW_ACCESS_KEY = 'XXXXXXXXXXXXXXX' API_CLIENT_ID = 'XXXXXXXXXXXXXXX' API_CLIENT_SECRET = 'XXXXXXXXXXXXXXX' - -# Shopware Config -SW_PAYMENT_FINISH_URL = 'http://localhost:3000/checkout/success' -SW_PAYMENT_ERROR_URL = 'http://localhost:3000/checkout/error' ``` ## Composables diff --git a/docs/pwa/what/installation.md b/docs/pwa/what/installation.md index d3110d95..c4b89967 100644 --- a/docs/pwa/what/installation.md +++ b/docs/pwa/what/installation.md @@ -30,18 +30,12 @@ modules: [ 4. Create a .env file in project root and fill credentials ```sh -APP_BASE_URL = 'http://localhost:3000' - PLATFORM = 'shopware' PLATFORM_BASE_URL = '' API_BASE_URL = '' API_SW_ACCESS_KEY = '' API_CLIENT_ID = '' API_CLIENT_SECRET = '' - -# Shopware Config -SW_PAYMENT_FINISH_URL = 'http://localhost:3000/checkout/success' -SW_PAYMENT_ERROR_URL = 'http://localhost:3000/checkout/error' ``` ::: tip Read more about where to get the credentials in the [supported e-commerce platforms](/pwa/what/requirements.html#supported-e-commerce-platforms) section. diff --git a/docs/pwa/what/overview.md b/docs/pwa/what/overview.md index 3bf661b6..b78dc55b 100644 --- a/docs/pwa/what/overview.md +++ b/docs/pwa/what/overview.md @@ -58,18 +58,12 @@ modules: [ 4. Create a .env file in project root and fill credentials ```sh -APP_BASE_URL = 'http://localhost:3000' - PLATFORM = 'shopware' PLATFORM_BASE_URL = '' API_BASE_URL = '' API_SW_ACCESS_KEY = '' API_CLIENT_ID = '' API_CLIENT_SECRET = '' - -# Shopware Config -SW_PAYMENT_FINISH_URL = 'http://localhost:3000/checkout/success' -SW_PAYMENT_ERROR_URL = 'http://localhost:3000/checkout/error' ``` ::: tip Read more about where to get the credentials in the [supported e-commerce platforms](/pwa/what/requirements.html#supported-e-commerce-platforms) section. diff --git a/src/platforms/shopware/composables/useCheckout.ts b/src/platforms/shopware/composables/useCheckout.ts index 1c260fd1..6491cb01 100644 --- a/src/platforms/shopware/composables/useCheckout.ts +++ b/src/platforms/shopware/composables/useCheckout.ts @@ -1,6 +1,6 @@ import { ref, Ref } from 'vue' import { LocationQuery } from 'vue-router' -import { useRuntimeConfig } from '#app' +import { useRequestURL } from '#app' import { defineStore, storeToRefs } from 'pinia' import { HblIUseCheckout, HblPaymentMethod, HblShippingMethod } from '@/utils/types' import { @@ -38,7 +38,6 @@ export const useCheckout = function (): HblIUseCheckout { const { deleteCart } = useCart() const { showNotification } = useNotification() const { currentRoute } = useRouter() - const config = useRuntimeConfig() const { navigateToI18n } = useLocalisation() const checkoutStore = useCheckoutStore() @@ -205,8 +204,8 @@ export const useCheckout = function (): HblIUseCheckout { const response = await PaymentShippingShopware.handlePaymentMethod( { orderId, - finishUrl: `${config.public.swPaymentFinishUrl}?orderId=${orderId}`, - errorUrl: `${config.public.swPaymentErrorUrl}?orderId=${orderId}`, + finishUrl: `${useRequestURL().origin}/checkout/success?orderId=${orderId}`, + errorUrl: `${useRequestURL().origin}/checkout/error?orderId=${orderId}`, // TODO: patch api client // @ts-ignore ...(dataBag != null && { ...dataBag }) diff --git a/src/platforms/shopware/composables/usePage.ts b/src/platforms/shopware/composables/usePage.ts index 2f0a011f..f3e7251c 100644 --- a/src/platforms/shopware/composables/usePage.ts +++ b/src/platforms/shopware/composables/usePage.ts @@ -1,6 +1,6 @@ import { Ref, ref } from 'vue' import { RouteLocationNormalizedLoaded } from 'vue-router' -import { useRouter } from '#app' +import { useRouter, useRequestURL } from '#app' import { HblIUsePage, HblPage, @@ -17,7 +17,7 @@ import { Product as swProduct } from '@hubblecommerce/hubble/platforms/shopware/api-client' import { request as __request } from '@hubblecommerce/hubble/platforms/shopware/request' -import { useLocalisation, useRuntimeConfig, hblMapPage, hblMapProductListing, hblMapProduct } from '#imports' +import { useLocalisation, hblMapPage, hblMapProductListing, hblMapProduct } from '#imports' const associations = { media: {}, @@ -32,7 +32,6 @@ export const usePage = function (): HblIUsePage { const loading: Ref = ref(false) const error: Ref = ref(false) const page: Ref = ref(null) - const runtimeConfig = useRuntimeConfig() const { currentRoute } = useRouter() const { isLocalisedRoute } = useLocalisation() @@ -144,7 +143,7 @@ export const usePage = function (): HblIUsePage { // Write parameters to current url without reloading the page function updateUri (params: any): void { - const url = new URL(runtimeConfig.public.appBaseUrl + currentRoute.value.path) + const url = new URL(useRequestURL().origin + currentRoute.value.path) url.search = new URLSearchParams(params).toString() window.history.pushState( {}, diff --git a/src/platforms/shopware/config/.env_example b/src/platforms/shopware/config/.env_example index fe691c43..95dbfa4e 100644 --- a/src/platforms/shopware/config/.env_example +++ b/src/platforms/shopware/config/.env_example @@ -1,12 +1,6 @@ -APP_BASE_URL = 'http://localhost:3000' - PLATFORM = 'shopware' PLATFORM_BASE_URL = '' API_BASE_URL = '' API_SW_ACCESS_KEY = '' API_CLIENT_ID = '' API_CLIENT_SECRET = '' - -# Shopware Config -SW_PAYMENT_FINISH_URL = 'http://localhost:3000/checkout/success' -SW_PAYMENT_ERROR_URL = 'http://localhost:3000/checkout/error' diff --git a/src/platforms/shopware/config/config.ts b/src/platforms/shopware/config/config.ts index 078e5a6b..911a2e7b 100644 --- a/src/platforms/shopware/config/config.ts +++ b/src/platforms/shopware/config/config.ts @@ -17,12 +17,9 @@ export const defaultPublicRuntimeConfig = { metaDescription: 'Official hubble demo page.' } }, - appBaseUrl: process.env.APP_BASE_URL, platformBaseUrl: process.env.PLATFORM_BASE_URL, apiBaseUrl: process.env.API_BASE_URL, - apiSwAccessKey: process.env.API_SW_ACCESS_KEY, - swPaymentFinishUrl: process.env.SW_PAYMENT_FINISH_URL, - swPaymentErrorUrl: process.env.SW_PAYMENT_ERROR_URL + apiSwAccessKey: process.env.API_SW_ACCESS_KEY } export const defaultPrivateRuntimeConfig = { From c54ddaf84a5e8462a587b41278d424707a91ca56 Mon Sep 17 00:00:00 2001 From: dm-heinze Date: Fri, 30 Jun 2023 13:13:12 +0200 Subject: [PATCH 02/65] issue#147 guest checkout: fixed back to cart link (#150) --- src/theme/pages/checkout/index.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/theme/pages/checkout/index.vue b/src/theme/pages/checkout/index.vue index 7723493f..8fb3543b 100644 --- a/src/theme/pages/checkout/index.vue +++ b/src/theme/pages/checkout/index.vue @@ -158,9 +158,9 @@ diff --git a/src/theme/components/customer/CustomerAddressBook.vue b/src/theme/components/customer/CustomerAddressBook.vue index 9554b5c0..e1336579 100644 --- a/src/theme/components/customer/CustomerAddressBook.vue +++ b/src/theme/components/customer/CustomerAddressBook.vue @@ -34,12 +34,14 @@ -