Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: Shopify Discount Function - Missing i18n manager

Shopify Discount Function - Missing i18n manager

websensepro
Shopify Partner
1854 215 261

Hi Guys, 

 

I tried following this tutorial https://shopify.dev/docs/apps/selling-strategies/discounts/discount-function-examples/order-minimum-... to Create Shopify Discount Function app 

 

After following all of the steps I am getting following error:

websensepro_0-1713342675785.png

 

Can anyone help me with this?

 

Need a Shopify developer? Hire us at WebSensePro For Shopify Design Changes/Coding
For Free Tutorials Subscribe to our youtube
Get More Sales Using Big Bulk Discount APP
Create Your Shopify Store For Just 1$/Month
Get More Sales Using Big Bulk Discount APP
Replies 3 (3)

Hirano_00
Shopify Partner
86 10 13

I think adding I18nContext to `app/routes/app.jsx` as follows will solve the problem.

 

import {I18nContext, I18nManager} from '@shopify/react-i18n';  // <-- add code

export default function App() {
  const { apiKey, host } = useLoaderData();
  const [config] = useState({ host, apiKey });
  const i18nManager = new I18nManager({   // <-- add code
    locale: 'en'
  });

  return (
    <AppProvider isEmbeddedApp apiKey={apiKey}>
      <I18nContext.Provider value={i18nManager}>   // <-- add code
        <DiscountProvider>
          <Outlet />
        </DiscountProvider>
      </I18nContext.Provider>.                     // <-- add code
    </AppProvider>
  );
}

 

kristi01
Shopify Partner
6 0 0

I have tried adding the same code, but I still encounter an error.



Minal07Bhuva_0-1718012281614.png

 

 

midavis
Shopify Partner
9 0 0

I had the same issue until I realized <Outlet/> was not inside the DiscountProvider Tag.  Should be

<AppProvider isEmbeddedApp apiKey={apiKey}>
      <DiscountProvider>
        <Outlet />
      </DiscountProvider>
</AppProvider>
 
and I mistakenly had it as
 
<AppProvider isEmbeddedApp apiKey={apiKey}>
      <DiscountProvider>
      </DiscountProvider>
      <Outlet />
</AppProvider>
 
Once I did this I did not need the I18nContext.Provider at all