<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nate Stewart on Medium]]></title>
        <description><![CDATA[Stories by Nate Stewart on Medium]]></description>
        <link>https://medium.com/@becomevocal?source=rss-955e84f2990d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*RmvjrpFNeKCho2cp</url>
            <title>Stories by Nate Stewart on Medium</title>
            <link>https://medium.com/@becomevocal?source=rss-955e84f2990d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 08:00:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@becomevocal/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Build a Multi-Region Storefront with BigCommerce for WordPress 3.1.0+]]></title>
            <link>https://medium.com/bigcommerce-developer-blog/build-a-multi-region-storefront-with-bigcommerce-for-wordpress-3-1-0-80cf56c3e8e9?source=rss-955e84f2990d------2</link>
            <guid isPermaLink="false">https://medium.com/p/80cf56c3e8e9</guid>
            <category><![CDATA[how-to]]></category>
            <category><![CDATA[bigcommerce]]></category>
            <category><![CDATA[wordpress]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[ecommerce]]></category>
            <dc:creator><![CDATA[Nate Stewart]]></dc:creator>
            <pubDate>Fri, 21 Jun 2019 15:11:36 GMT</pubDate>
            <atom:updated>2019-06-21T15:11:36.863Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gRxYm4URUxOdzxRy" /></figure><p>Earlier this month, we released <a href="https://medium.com/bigcommerce-developer-blog/new-release-bigcommerce-for-wordpress-3-1-0-9bbe436153d8">version 3.1.0</a> of BigCommerce for WordPress, but unless you’re looking closely, you might have missed some new functionality that’s a pretty big deal.</p><p>Version 3.1.0 introduced support for the ability to create and manage channel views within a single instance of WordPress and BigCommerce, which lays the foundation for developers to build multi-region, multi-experience ecommerce sites. In our latest release, <a href="https://medium.com/bigcommerce-developer-blog/new-release-bigcommerce-for-wordpress-3-2-0-13fab02eecb5">version 3.2.0</a>, we’ve added enhancements that streamline the process of working with products across multiple channels.</p><p>Multi is not an entirely new concept for BigCommerce for WordPress. In previous versions of the plugin, you could link a single BigCommerce store to <a href="https://medium.com/bigcommerce-developer-blog/multi-site-ecommerce-with-wordpress-and-bigcommerce-40dee194f8a">multiple WordPress instances</a>. In that configuration, each WordPress site represents a different channel. You could list different products and show a different front end experience on each channel site connected to the plugin.</p><p>The new multi-channel functionality takes that concept a step further.</p><p>Now, you don’t need to spin up a new WordPress instance for each channel — you can utilize multiple channels from within a <em>single</em> WordPress site. We’ve made it possible to manage which products are listed per channel in BigCommerce and the catalog variations between those channels from the WordPress admin, and we’ve built a lot of flexibility into the model in order to support a wide range of use cases.</p><p>In this post, we’ll demo some of the new plugin capabilities and provide an example to illustrate how you can set up a multi-region storefront with minimal code.</p><p>This is also a representation of what is possible with our public APIs <em>today</em>. If you are looking to implement your own custom storefront and it needs to support more than one region, you can apply the concepts here too.</p><h3>Our Approach to Serving Multiple Regions</h3><p>One of the key characteristics of a multi-channel architecture is that multiple user-facing experiences share a single backend. With BigCommerce for WordPress, and with other channel integrations built on BigCommerce, that single backend is BigCommerce, which is the source of truth for the catalog, orders, and customers.</p><p>A single product might be listed on several channels, and across those channels, the product details may vary. For example, a pair of sneakers that’s sold on a site serving the US region might have a different price and description than the pair that is sold on the French site. But despite those variations, there is a single product record for the pair of sneakers which is managed from the BigCommerce control panel. Similarly, orders placed on different channels all flow into a single admin view within BigCommerce, and each order is attributed back to its channel source. This allows you to maintain a central source of truth for managing your orders, while tracking sales performance across various channels. No need to jump around into different accounts!</p><h3>Primary Use Cases</h3><p>Let’s begin with a common multi-site use cases: multi-region. Businesses with a global footprint have the need to tailor product merchandising to the regions where they do business, which means translating product details into the local language and showing prices in the proper currency.</p><p>While you could serve multiple regions with separate sites, there are advantages to orchestrating multiple experience from a single site. Lower overhead and a streamlined workflow for managing site admin are a few major considerations. The BigCommerce for WordPress plugin consolidates multiple channels into a single product view, giving you the ability to filter products by channel and edit product details on a channel-specific basis.</p><p>That being said, the BigCommerce for WordPress multi-store functionality isn’t tied only to multi-region. You could potentially build multi-store experiences around a range of broader use cases including B2B scenarios like separate wholesale and retail sites or “vendor portals”, featuring a product catalog specific to each vendor.</p><p>The reason for this versatility is that multi-channel is controlled within the plugin using two hooks: one that activates the multi-channel functionality within the plugin and another that wraps the logic for changing channels. The important distinction is that we allow developers to define that logic themselves, which means that the trigger for changing channel views can be anything — the shopper’s geo IP, a customer attribute — any condition that you can detect.</p><h3>Multi-region Implementation Examples</h3><p>In this section we’ll dive into enabling multi-region storefronts. These two different examples are based on simple child plugins I put together, which trigger the channel view when a user’s region is France. The French channel includes product details that have been translated into the appropriate language and also switches the currency code and symbol to Euro.</p><p><em>Note: Both examples have a sample child plugin you can download as a starter at the bottom of this post.</em></p><h4>First, Enable multi-channel</h4><p>For both examples, the BigCommerce for WordPress multi-channel mode is enabled using this filter:</p><pre>add_filter( ‘bigcommerce/channels/enable-multi-channel’, ‘__return_true’ );</pre><p>With the enable-multi-channel functionality activated, we can supply logic to change the channel view based on a condition that we define — like the user’s location. This filter also activates changes within the admin interface that allow users to manage channel listings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jk3RhzlZuEJbzZix" /></figure><p>A simple way to get the term id for a channel, which you’ll need later, is to hover over one of the ‘rename’, ‘make primary’ or ‘disconnect’ actions here to see the term id in the url.</p><h4>Triggering a region via Geo IP lookup</h4><p>A common requirement for multi-region implementations is automatically selecting the right region based on the shopper’s geo location. We’ll unlock this with help from the free <a href="https://wordpress.org/plugins/geoip-detect/">GeoIP Detection</a> plugin to detect the user’s location based on geo IP. By default, the plugin reaches out to an API for geolocation data, but you can also specify a database to pull location data from instead. I used the GeoLite2 City database, which you can enable during the GeoIP plugin setup.</p><p>The GeoIP Detection plugin supplies this function, which does a lookup of geo-location data for the current user:</p><pre>geoip_detect2_get_info_from_current_ip()</pre><p>The child plugin I built uses this function to check the user’s location against the country code ‘FR’ <em>if </em>the GeoIP detect plugin is also installed (so there isn’t an error when the child plugin calls the function above).</p><p>The logic looks like this:</p><pre>$userInfo = geoip_detect2_get_info_from_current_ip();</pre><pre>if (function_exists(&#39;geoip_detect2_get_info_from_current_ip&#39;)) {<br>  if ($userInfo-&gt;country-&gt;isoCode == &#39;FR&#39;) {<br>    <em>// Switch from primary channel (US in the demo) to FR channel</em><br>  }<br>} else {<br>  // Echo out warning that GeoIP detect plugin is not act<br>}</pre><p><strong>Change the channel view</strong></p><p>Here’s where the multi magic happens. If the shopper’s location matches France, we trigger three changes:</p><p>1) we set the current channel to the one containing French product listings</p><p>2) change the currency code to ‘EUR’, and</p><p>3) switch the currency symbol to ‘€’.</p><p>Within the code these changes are done with the following WordPress filters:</p><pre>add_filter(&#39;bigcommerce/channel/current&#39;, function($channel) {<br> return get_term(41, \BigCommerce\Taxonomies\Channel\Channel::NAME);<br>}, 10, 1);</pre><pre>add_filter(&#39;pre_option_&#39; . &#39;bigcommerce_currency_code&#39;, function() {<br> return &#39;EUR&#39;;<br>}, 10, 0);</pre><p>If you have the <a href="https://www.php.net/manual/en/intl.installation.php">php-intl</a> extension on your server, the currency formatting will automatically work out at this point. If you don’t, there are additional filters to use that are explicit:</p><pre>add_filter(&#39;pre_option_bigcommerce_currency_symbol&#39;, function() {<br> return &#39;€&#39;;<br>}, 10, 0);</pre><pre>add_filter(&#39;pre_option_bigcommerce_currency_symbol_position&#39;, function() {<br> return &#39;left&#39;;<br>}, 10, 0);</pre><pre>add_filter(&#39;pre_option_bigcommerce_decimal_units&#39;, function() {<br> return 2;<br>}, 10, 0);</pre><pre>add_filter(&#39;pre_option_bigcommerce_integer_units&#39;, function() {<br> return 16;<br>}, 10, 0);</pre><p>Added up into something runnable, the code looks like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d24a100597cc49288b3a415c210c8199/href">https://medium.com/media/d24a100597cc49288b3a415c210c8199/href</a></iframe><p><strong>Testing GeoIP Triggering</strong></p><p>You can test the French channel on the storefront using a VPN or a cloud-based geo tester like <a href="https://www.locabrowser.com/">LocaBrowser</a> to appear as if you are in a French location.</p><h4>Triggering a region via Query String</h4><p>Another common implementation is using the url as a trigger for a specific locale. Using much of the same logic but replacing the GeoIP check with a query string check, I produced another child plugin example in a matter of minutes.</p><p>From a high level, the code is now:</p><pre>if ( $_GET[ &#39;region&#39; ] !== &#39;en&#39; &amp;&amp; ($_GET[ &#39;region&#39; ] === &#39;fr&#39; || strpos($_SERVER[&#39;HTTP_REFERER&#39;], &#39;region=fr&#39;) !== false) ) {</pre><pre> // Same channel filters as the GeoIP example</pre><pre>}</pre><p><strong>Adding a Region Selector</strong></p><p>To allow the user to switch back and forth between the US and French regions on the storefront, I added a simple menu, based on a <a href="https://codepen.io/axel1998/pen/RWOpXq">Code Pen</a> published by Axel Köhler.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LZsX-xxMSwARcnhJw5DT_A.png" /></figure><p>Here’s the PHP code for the region selector:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3cfc3c528b75a66c87c38cccc021edb1/href">https://medium.com/media/3cfc3c528b75a66c87c38cccc021edb1/href</a></iframe><p>And some CSS to style it:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/65b238f9d559d361b94189495bf365b3/href">https://medium.com/media/65b238f9d559d361b94189495bf365b3/href</a></iframe><p>I also added this to mask the ‘flash’ of the pricing loading for a specific channel:</p><pre>.bc-product__pricing--cached { visibility: hidden !important; }</pre><p>In the child plugin for this example, the PHP template and CSS for the menu are included. This means you don’t have to modify your theme files to accomplish this UX, which is a nice perk.</p><p>The end result is this region selection UX:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RnpJuGtr2oHdnKL5VVS1dA.gif" /></figure><h3>Example Child Plugin Downloads</h3><p>Jump start your development with one of these child plugins, based on the examples above:</p><ul><li>By GeoIP: <a href="http://bit.ly/bc4wp-geoip-region-activation">http://bit.ly/bc4wp-geoip-region-activation</a></li><li>By Query String: <a href="http://bit.ly/bc4wp-query-string-activation">http://bit.ly/bc4wp-query-string-activation</a></li></ul><h3>Conclusion</h3><p>While a production-ready multi-region site would be more complex than what we’ve covered here, the purpose of this demo is to illustrate how BigCommerce for WordPress gives developers the tools to unlock multi-region capabilities with relatively little code.</p><p>More documentation on the BigCommerce for WordPress multi-channel mode will be coming soon, and be sure to keep tabs on our <a href="https://github.com/bigcommerce/bigcommerce-for-wordpress/releases">BC4WP releases in GitHub</a> for the latest additions to the plugin.</p><p>Also, note that since BC4WP is using public BigCommerce APIs to make all this happen, <em>all these concepts can apply to any headless commerce implementation</em>.</p><p>We’re excited to see where the community takes this, and we’d also love your feedback. Let us know what you’re building in the comments below and join the conversation by tweeting @BigCommerceDevs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80cf56c3e8e9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bigcommerce-developer-blog/build-a-multi-region-storefront-with-bigcommerce-for-wordpress-3-1-0-80cf56c3e8e9">Build a Multi-Region Storefront with BigCommerce for WordPress 3.1.0+</a> was originally published in <a href="https://medium.com/bigcommerce-developer-blog">BigCommerce Developer Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a BigCommerce App Using Laravel and React]]></title>
            <link>https://medium.com/bigcommerce-developer-blog/building-a-bigcommerce-app-using-laravel-and-react-711ceceb5006?source=rss-955e84f2990d------2</link>
            <guid isPermaLink="false">https://medium.com/p/711ceceb5006</guid>
            <category><![CDATA[apps]]></category>
            <category><![CDATA[how-to]]></category>
            <category><![CDATA[bigcommerce]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Nate Stewart]]></dc:creator>
            <pubDate>Thu, 25 Apr 2019 15:51:29 GMT</pubDate>
            <atom:updated>2023-08-31T15:14:33.826Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q96mNrElGYIeF02uc4JXqA.png" /></figure><p>As Head of Product Strategy at BigCommerce, I often get to work with developers that are looking to quickly extend what our platform can do and enable a UI for merchants to interface with the new functionality they create. Something I’ve been wanting to offer those developers is a way to fast-track their concepts into a functional app on our platform — a boilerplate app using a popular BE and FE framework that is easily accessible.</p><p><em>While waiting for that problem to be magically solved</em>, I had been prototyping a concept on my own time using some of our new <a href="https://developer.bigcommerce.com/api-docs/storefront/widgets/widgets-overview">Widget APIs</a>, and realized out of necessity I had already created the foundation for a simple Laravel &amp; React based app in the process.</p><p>This tutorial will walk you through the steps to get a functional application using Laravel on the backend and React on the front end up and running. Its purpose is to fast-track your understanding of what it takes to quickly build a BigCommerce application using approachable, modern frameworks.</p><p>In the end, you will have a basic two-screen application with routing. You can run it locally, or install it on your BigCommerce store. Run API requests, display the results, and make actions.</p><p>And yes, <em>the link to GitHub with the final code is at the bottom</em>.</p><ul><li><em>Disclaimer this article this article has been updated from its original version &amp; has been updated in 2023 with support for Laravel 10.</em></li><li><em>Credit for the source of work put into updating the repo, and the following updated documentation goes to Johan Nielsen of BigCommerce.</em></li></ul><h3>Prerequisites</h3><p>Before jumping in, you’ll want to make sure you have installed the following dependencies on your dev machine:</p><ul><li>PHP (<a href="https://www.php.net/manual/en/install.php">Installation Guide</a>)</li><li>Composer (<a href="https://getcomposer.org/doc/00-intro.md">Installation Guide</a>)</li><li>Laravel (<a href="https://laravel.com/docs/10.x">Installation Guide</a>)</li><li>Local SSL Cert (Recommend Valet or Homestead to ease set up)</li></ul><p>To ease PHP development and enable the app you develop to be easily shared, you’ll want to use either Valet or Homestead, depending on your OS:</p><ul><li>Mac OS: Valet (<a href="https://laravel.com/docs/10.x/valet">Installation Guide</a>)</li><li>Windows / Linux: Homestead (<a href="https://laravel.com/docs/10.x/homestead">Installation Guide</a>)</li></ul><p>We’ll be using Valet for some of the steps below, but the functionality to host and share sites is similar across both Valet and Homestead. What’s more important in this tutorial is how to configure Laravel to use React and connect with BigCommerce.</p><p>Let’s get started!</p><h3>Step 1: Getting Laravel and React Running Together</h3><p>This is where we will create a baseline for future development: a simple application that loads at a specific URL in your browser and loads a React component instead of the default Laravel screen.</p><h4>Create a new Laravel codebase</h4><p>You can either use the Laravel command that creates the initial boilerplate for an app in the ~/Sites directory or use Composer:</p><pre>composer global require laravel/installer<br>laravel new laravel-react-bigcommerce-app</pre><p>or</p><pre>composer create-project laravel/laravel <br>laravel-react-bigcommerce-app</pre><p>You should see the command run its course, like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gJA9OxV3pmjXTcZNpXvFpg.png" /></figure><h4>Visit the app address to make sure it’s live locally</h4><p>After the command above completes, we will need to set up the directory so Valet can serve the app securely.</p><pre>cd laravel-react-bigcommerce-app<br>valet link<br>valet secure</pre><p>You should now be able to visit the following URL in your browser and see the default Laravel welcome screen:</p><p><a href="https://laravel-react-bigcommerce-app.test/">https://laravel-react-bigcommerce-app.test</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OG0DTy6-dlhA64sJX5ZPWA.png" /></figure><h4>Set up React as the JS framework using Breeze and Inertia</h4><p>Larvel Breeze provides a minimal and simple starting point for building a Laravel application, with authentication features. It’s powered by Blade and Tailwind but can be configured as an SPA using Inertia. In this example, we will power our front end with react.</p><p>First, let’s install Breeze:</p><pre>composer require laravel/breeze --dev</pre><p>Then we install the react scaffolding:</p><pre>php artisan breeze:install react</pre><p>Note: this last command executed npm install so no need to run this command.</p><p>Lastly, get the application running:</p><pre>npm run dev</pre><p>A Local URL should now be available in your console to visit your react application: <a href="http://127.0.0.1:5173/">http://127.0.0.1:5173/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7zkFlG0cuId8B9K2O9BJdw.png" /></figure><h3>References</h3><ul><li><a href="https://laravel.com/docs/10.x/installation#your-first-laravel-project">Installing Your First Laravel Project</a></li><li><a href="https://laravel.com/docs/10.x/starter-kits">Laravel Starter Kits</a></li></ul><h3>Step 2: Set up a Basic App</h3><p>Now that you are set up for React development with a Laravel back-end, you are ready to implement routes, pages, and navigation within the app.</p><h4>Routes</h4><p>Open up /routes/web.php and edit the file to reflect the following routes:</p><pre>Route::get(&#39;/&#39;, function () {<br>    return Inertia::render(&#39;Home&#39;);<br>});<br><br>Route::get(&#39;/list&#39;, function () {<br>    return Inertia::render(&#39;List&#39;);<br>});</pre><p><strong>Note:</strong> <em>Breeze installs scaffolding for authentication routes to be used with your React app. You’ll have to modify them if you intend to use these routes in the future, or replace them with above routes</em></p><h4>Pages</h4><p>Create /resources/js/Pages/Home.jsx</p><pre>import Navigation from &#39;@/Components/Navigation&#39;;<br><br>import { Head } from &#39;@inertiajs/react&#39;;<br>import React from &#39;react&#39;;<br><br>export default class Home extends React.Component {<br>    render() {<br>        return (<br>            &lt;&gt;<br>                &lt;Head title=&quot;Home&quot; /&gt;<br>                &lt;Navigation /&gt;<br><br>                &lt;div className=&quot;container mx-auto p-5&quot;&gt;<br>                    &lt;div className=&quot;grid grid-cols-4 gap-4&quot;&gt;<br>                        &lt;div className=&quot;content col-span-3 grid-col-3 rounded bg-gray-100 shadow-lg p-4&quot;&gt;<br>                            &lt;h2 className=&quot;text-xl font-bold mb-6&quot;&gt;This is the Home Page.&lt;/h2&gt;<br>                        &lt;/div&gt;<br>                        &lt;div className=&quot;sidebar rounded bg-gray-100 shadow-lg p-4&quot;&gt;<br>                            &lt;h2 className=&quot;text-xl font-bold mb-6&quot;&gt;This is a Side Bar.&lt;/h2&gt;<br>                        &lt;/div&gt;<br>                    &lt;/div&gt;<br>                &lt;/div&gt;<br>            &lt;/&gt;<br>        );<br>    }<br>}</pre><p>Create /resources/js/Pages/List.jsx</p><pre>import Navigation from &#39;@/Components/Navigation&#39;;<br><br>import { Head } from &#39;@inertiajs/react&#39;;<br>import React from &#39;react&#39;;<br><br>export default class List extends React.Component {<br>    render() {<br>        return (<br>            &lt;&gt;<br>                &lt;Head title=&quot;Order List&quot; /&gt;<br>                &lt;Navigation /&gt;<br><br>                &lt;div className=&quot;container mx-auto p-5&quot;&gt;<br>                    &lt;div className=&quot;content col-span-3 grid-col-3 rounded bg-gray-100 shadow-lg p-4&quot;&gt;<br>                        &lt;h2 className=&quot;text-xl font-bold mb-6&quot;&gt;List of Orders&lt;/h2&gt;<br>                    &lt;/div&gt;<br>                &lt;/div&gt;<br>            &lt;/&gt;<br>        );<br>    }<br>}<br><br></pre><h4>Navigation Component</h4><p>When creating the two pages above you may have noticed we imported a navigation component. Let’s create it!</p><p>Create /resources/js/Components/Navigation.jsx</p><pre>import { Link } from &#39;@inertiajs/react&#39;;<br><br>export default function Navigation() {<br>    return (<br>        &lt;nav className=&quot;flex items-center justify-between flex-wrap bg-gray-500 p-6&quot;&gt;<br>            &lt;div className=&quot;flex items-center flex-shrink-0 text-white mr-6&quot;&gt;<br>                &lt;ul className=&quot;flex&quot;&gt;<br>                    &lt;li className=&quot;mr-6&quot;&gt;<br>                        &lt;Link className=&quot;text-white hover:text-blue-800&quot; href=&quot;/&quot;&gt;Home&lt;/Link&gt;<br>                    &lt;/li&gt;<br>                    &lt;li className=&quot;mr-6&quot;&gt;<br>                        &lt;Link className=&quot;text-white hover:text-blue-800&quot; href=&quot;/list&quot;&gt;List&lt;/Link&gt;<br>                    &lt;/li&gt;<br>                &lt;/ul&gt;<br>            &lt;/div&gt;<br>        &lt;/nav&gt;<br>    );<br>};<br><br></pre><h4>Summary</h4><p>You should now have a working application with React, Routes, Pages, and Components. Navigate to <a href="https://laravel-react-bigcommerce-app.test/">https://laravel-react-bigcommerce-app.test</a> and you’ll now see a functional layout for an app, including navigation, appear!</p><h3>Step 3: Connect the App with BigCommerce</h3><p>Alright, it’s time to start connecting the app to real data inside a BigCommerce store.</p><h4>Create app in the BigCommerce dev tools area</h4><p>Head to <a href="https://devtools.bigcommerce.com/">devtools.bigcommerce.com</a> and log in with your BigCommerce store account. Create an app and go to the ‘Technical’ step in the modal.</p><p>To start, you want at least the auth and load callback URLs to be set, since those are what BigCommerce will use to initiate the install process and enable the app to load within the BigCommerce control panel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QyEW0OLQZoFAiyPG8215Xw.png" /></figure><p>After setting the callback URLs, you need to select which scopes your app will need. Keep track of this because your app will need to check the proper scopes have been granted when installed. If you were making a real app, you would only select what the app actually needs here, as BigCommerce will work to ensure you don’t have too many permissions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pW_WduLUWzf4j20EH9UQIQ.png" /></figure><h4>Save your app’s client ID and secret</h4><p>The client ID and Secret are used to verify that your app requests are valid. Save these into environment variables within your app. In the sample Laravel app, we’re saving these in the .env file along with the scopes so each piece of app info is able to be set in one place.</p><p>Update your .env file (in the root app directory) to have the APP_URL set as <a href="https://laravel-react-bigcommerce-app.test/">https://laravel-react-bigcommerce-app.test</a> and add new env variables at the bottom of the file for your BigCommerce App IDs and test API credentials for local dev.</p><pre># Existing env variable. Make sure it matches the base URL of your app<br>APP_URL=https://laravel-react-bigcommerce-app.test<br><br>[ ... other existing variables ... ]<br><br># New env variables for BigCommerce app and a test API credentials for local dev<br># The Client ID and Secret can be found at https://devtools.bigcommerce.com/my/apps by selecting &#39;View Client ID&#39;<br>BC_APP_CLIENT_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br>BC_APP_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br><br># These local credentials can be created by creating an API Account within your BigCommerce store (Advanced Settings &gt; Store Level API Account)<br>BC_LOCAL_CLIENT_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br>BC_LOCAL_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br>BC_LOCAL_ACCESS_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br>BC_LOCAL_STORE_HASH=stores/xxxxxxxxxxx</pre><h4>Set up the install, load and BigCommerce API proxy routes</h4><p>When the app is installed, it will look at the callbacks that are defined in the dev tools area.</p><p>Add the web routes below &amp; use App\Http\Controllers\MainController; to web.php found in laravel-react-sample-app/routes/web.php, so Laravel knows to route to the specific controller methods for each callback. We are implementing install and load here, to get the baseline experience working, however, there are stubbed routes for future functionality like uninstall and remove-user.</p><pre>use App\Http\Controllers\MainController; //add this to the top of the page<br><br>Route::get(&#39;/{url?}&#39;, function () {<br>    return view(&#39;app&#39;);<br>})-&gt;where(&#39;&#39;, &#39;list&#39;);<br><br>Route::group([&#39;prefix&#39; =&gt; &#39;auth&#39;], function () {<br>  Route::get(&#39;install&#39;, &#39;MainController@install&#39;);<br><br>  Route::get(&#39;load&#39;, &#39;MainController@load&#39;);<br><br>  Route::get(&#39;uninstall&#39;, function () {<br>    echo &#39;uninstall&#39;;<br>    return app()-&gt;version();<br>  });<br><br>  Route::get(&#39;remove-user&#39;, function () {<br>    echo &#39;remove-user&#39;;<br>    return app()-&gt;version();<br>  });<br>});<br><br>Route::any(&#39;/bc-api/{endpoint}&#39;, &#39;MainController@proxyBigCommerceAPIRequest&#39;)<br>  -&gt;where(&#39;endpoint&#39;, &#39;v2\/.*|v3\/.*&#39;);</pre><h4>Create a controller to handle app install and load requests, proxy BigCommerce API</h4><p>You can see above that there are references to ‘MainController’. That is where we’ll put the logic that handles the OAuth handshake and stores the credentials generated for the store. Remember that this uses session-based storage, so when the browser session expires, the app will stop working.</p><p>The last route is a proxy through to the BigCommerce v2 and v3 APIs. We’ll use that to enable a bc-api endpoint we can hit on the front end, which helps us bypass CORS issues.</p><p>Create /app/Http/Controllers/MainController.php</p><pre>&lt;?php<br><br>namespace App\Http\Controllers;<br><br>use Illuminate\Routing\Controller as BaseController;<br>use Illuminate\Http\Request;<br>use Illuminate\Http\RedirectResponse;<br>use Illuminate\Support\Facades\Redirect;<br><br>use GuzzleHttp\Exception\RequestException;<br><br>use GuzzleHttp\Client;<br><br>class MainController extends BaseController<br>{<br>    protected $baseURL;<br><br>    public function __construct()<br>    {<br>        $this-&gt;baseURL = env(&#39;APP_URL&#39;);<br>    }<br><br>    public function getAppClientId()<br>    {<br>        if (env(&#39;APP_ENV&#39;) === &#39;local&#39;) {<br>            return env(&#39;BC_LOCAL_CLIENT_ID&#39;);<br>        } else {<br>            return env(&#39;BC_APP_CLIENT_ID&#39;);<br>        }<br>    }<br><br>    public function getAppSecret(Request $request)<br>    {<br>        if (env(&#39;APP_ENV&#39;) === &#39;local&#39;) {<br>            return env(&#39;BC_LOCAL_SECRET&#39;);<br>        } else {<br>            return env(&#39;BC_APP_SECRET&#39;);<br>        }<br>    }<br><br>    public function getAccessToken(Request $request)<br>    {<br>        if (env(&#39;APP_ENV&#39;) === &#39;local&#39;) {<br>            return env(&#39;BC_LOCAL_ACCESS_TOKEN&#39;);<br>        } else {<br>            return $request-&gt;session()-&gt;get(&#39;access_token&#39;);<br>        }<br>    }<br><br>    public function getStoreHash(Request $request)<br>    {<br>        if (env(&#39;APP_ENV&#39;) === &#39;local&#39;) {<br>            return env(&#39;BC_LOCAL_STORE_HASH&#39;);<br>        } else {<br>            return $request-&gt;session()-&gt;get(&#39;store_hash&#39;);<br>        }<br>    }<br><br>    public function install(Request $request): RedirectResponse<br>    {<br>        // Make sure all required query params have been passed<br>        if (!$request-&gt;has(&#39;code&#39;) || !$request-&gt;has(&#39;scope&#39;) || !$request-&gt;has(&#39;context&#39;)) {<br>            return redirect()-&gt;action([MainController::class, &#39;error&#39;], [&#39;error_message&#39; =&gt; &#39;Not enough information was passed to install this app.&#39;]);<br>        }<br><br>        try {<br>            $client = new Client();<br>            $result = $client-&gt;request(&#39;POST&#39;, &#39;https://login.bigcommerce.com/oauth2/token&#39;, [<br>                &#39;json&#39; =&gt; [<br>                    &#39;client_id&#39; =&gt; $this-&gt;getAppClientId(),<br>                    &#39;client_secret&#39; =&gt; $this-&gt;getAppSecret($request),<br>                    &#39;redirect_uri&#39; =&gt; $this-&gt;baseURL . &#39;/auth/install&#39;,<br>                    &#39;grant_type&#39; =&gt; &#39;authorization_code&#39;,<br>                    &#39;code&#39; =&gt; $request-&gt;input(&#39;code&#39;),<br>                    &#39;scope&#39; =&gt; $request-&gt;input(&#39;scope&#39;),<br>                    &#39;context&#39; =&gt; $request-&gt;input(&#39;context&#39;),<br>                ]<br>            ]);<br><br>            $statusCode = $result-&gt;getStatusCode();<br>            $data = json_decode($result-&gt;getBody(), true);<br><br>            if ($statusCode == 200) {<br>                $request-&gt;session()-&gt;put(&#39;store_hash&#39;, $data[&#39;context&#39;]);<br>                $request-&gt;session()-&gt;put(&#39;access_token&#39;, $data[&#39;access_token&#39;]);<br>                $request-&gt;session()-&gt;put(&#39;user_id&#39;, $data[&#39;user&#39;][&#39;id&#39;]);<br>                $request-&gt;session()-&gt;put(&#39;user_email&#39;, $data[&#39;user&#39;][&#39;email&#39;]);<br><br>                // If the merchant installed the app via an external link, redirect back to the <br>                // BC installation success page for this app<br>                if ($request-&gt;has(&#39;external_install&#39;)) {<br>                    return Redirect::to(&#39;https://login.bigcommerce.com/app/&#39; . $this-&gt;getAppClientId() . &#39;/install/succeeded&#39;);<br>                }<br>            }<br><br>            return Redirect::to(&#39;/&#39;);<br>        } catch (RequestException $e) {<br>            $statusCode = $e-&gt;getResponse()-&gt;getStatusCode();<br>            $errorMessage = &quot;An error occurred.&quot;;<br><br>            if ($e-&gt;hasResponse()) {<br>                if ($statusCode != 500) {<br>                    $errorMessage = $e-&gt;getResponse();<br>                }<br>            }<br><br>            // If the merchant installed the app via an external link, redirect back to the <br>            // BC installation failure page for this app<br>            if ($request-&gt;has(&#39;external_install&#39;)) {<br>                return Redirect::to(&#39;https://login.bigcommerce.com/app/&#39; . $this-&gt;getAppClientId() . &#39;/install/failed&#39;);<br>            } else {<br>                return redirect()-&gt;action([MainController::class, &#39;error&#39;], [&#39;error_message&#39; =&gt; $errorMessage]);<br>            }<br>        }<br>    }<br><br>    public function load(Request $request): RedirectResponse<br>    {<br>        $signedPayload = $request-&gt;input(&#39;signed_payload&#39;);<br>        if (!empty($signedPayload)) {<br>            $verifiedSignedRequestData = $this-&gt;verifySignedRequest($signedPayload, $request);<br>            if ($verifiedSignedRequestData !== null) {<br>                $request-&gt;session()-&gt;put(&#39;user_id&#39;, $verifiedSignedRequestData[&#39;user&#39;][&#39;id&#39;]);<br>                $request-&gt;session()-&gt;put(&#39;user_email&#39;, $verifiedSignedRequestData[&#39;user&#39;][&#39;email&#39;]);<br>                $request-&gt;session()-&gt;put(&#39;owner_id&#39;, $verifiedSignedRequestData[&#39;owner&#39;][&#39;id&#39;]);<br>                $request-&gt;session()-&gt;put(&#39;owner_email&#39;, $verifiedSignedRequestData[&#39;owner&#39;][&#39;email&#39;]);<br>                $request-&gt;session()-&gt;put(&#39;store_hash&#39;, $verifiedSignedRequestData[&#39;context&#39;]);<br>                <br>            } else {<br>                return redirect()-&gt;action([MainController::class, &#39;error&#39;], [&#39;error_message&#39; =&gt; &#39;The signed request from BigCommerce could not be validated.&#39;]);<br>            }<br>        } else {<br>            return redirect()-&gt;action([MainController::class, &#39;error&#39;], [&#39;error_message&#39; =&gt; &#39;The signed request from BigCommerce was empty.&#39;]);<br>        }<br><br>        $request-&gt;session()-&gt;regenerate();<br><br>        return Redirect::to(&#39;/&#39;);<br>    }<br><br>    public function error(Request $request)<br>    {<br>        $errorMessage = &quot;Internal Application Error&quot;;<br><br>        if ($request-&gt;session()-&gt;has(&#39;error_message&#39;)) {<br>            $errorMessage = $request-&gt;session()-&gt;get(&#39;error_message&#39;);<br>        }<br><br>        echo &#39;&lt;h4&gt;An issue has occurred:&lt;/h4&gt; &lt;p&gt;&#39; . $errorMessage . &#39;&lt;/p&gt; &lt;a href=&quot;&#39; . $this-&gt;baseURL . &#39;&quot;&gt;Go back to home&lt;/a&gt;&#39;;<br>    }<br><br>    private function verifySignedRequest($signedRequest, $appRequest)<br>    {<br>        list($encodedData, $encodedSignature) = explode(&#39;.&#39;, $signedRequest, 2);<br><br>        // decode the data<br>        $signature = base64_decode($encodedSignature);<br>        $jsonStr = base64_decode($encodedData);<br>        $data = json_decode($jsonStr, true);<br><br>        // confirm the signature<br>        $expectedSignature = hash_hmac(&#39;sha256&#39;, $jsonStr, $this-&gt;getAppSecret($appRequest), $raw = false);<br>        if (!hash_equals($expectedSignature, $signature)) {<br>            error_log(&#39;Bad signed request from BigCommerce!&#39;);<br>            return null;<br>        }<br>        return $data;<br>    }<br><br>    public function makeBigCommerceAPIRequest(Request $request, $endpoint)<br>    {<br>        $requestConfig = [<br>            &#39;headers&#39; =&gt; [<br>                &#39;X-Auth-Client&#39; =&gt; $this-&gt;getAppClientId(),<br>                &#39;X-Auth-Token&#39;  =&gt; $this-&gt;getAccessToken($request),<br>                &#39;Content-Type&#39;  =&gt; &#39;application/json&#39;,<br>            ]<br>        ];<br><br>        if ($request-&gt;method() === &#39;PUT&#39;) {<br>            $requestConfig[&#39;body&#39;] = $request-&gt;getContent();<br>        }<br><br>        $client = new Client();<br>        $result = $client-&gt;request($request-&gt;method(), &#39;https://api.bigcommerce.com/&#39; . $this-&gt;getStoreHash($request) .&#39;/&#39;. $endpoint, $requestConfig);<br>        <br>        return $result;<br>    }<br><br>    public function proxyBigCommerceAPIRequest(Request $request, $endpoint)<br>    {<br>        if (strrpos($endpoint, &#39;v2&#39;) !== false) {<br>            // For v2 endpoints, add a .json to the end of each endpoint, to normalize against the v3 API standards<br>            $endpoint .= &#39;.json&#39;;<br>        }<br><br>        $result = $this-&gt;makeBigCommerceAPIRequest($request, $endpoint);<br><br>        return response($result-&gt;getBody(), $result-&gt;getStatusCode())-&gt;header(&#39;Content-Type&#39;, &#39;application/json&#39;);<br>    }<br>}</pre><p><strong>Note</strong>: <em>By default, your app is set to use your hardcoded API credentials in the .env file. When you install the app within BigCommerce, you want your app to use the credentials passed back during the OAuth token exchange. To do this, make sure your APP_ENV config value in your .env file is set to production, like so:</em></p><pre>APP_ENV=production</pre><p>Now, if you head to your BigCommerce store admin, to the Apps -&gt; My Apps -&gt; My Draft Apps section, you can install your app and see it successfully load inside the control panel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g8r6p2qHQKcdxw0mHP1zpA.png" /></figure><h3>Step 4. Create a front-end experience that surfaces data in BigCommerce</h3><p>All the pieces are in place to create front-end components that actually do something, so I created a simple set of React components and screens that:</p><ul><li>Load a brief catalog summary and store information</li><li>List the last 10 orders and enable the user to cancel them</li></ul><p>To enable the front-end components to hit the API using the back-end BigCommerce API Proxy endpoints in MainController.php, add the following files to a new /resources/js/Services/ directory:</p><h4>Create /resources/js/Services/ApiServices.js</h4><pre>export const ApiService = {<br>    getOrders(params) {<br>        params = Object.assign({<br>            page: 1,<br>            limit: 10,<br>        }, params);<br><br>        return axios({<br>            method: &#39;get&#39;,<br>            url: &#39;/bc-api/v2/orders&#39;,<br>            params,<br>        });<br>    },<br><br>    updateOrder(orderId, data) {<br>        return axios({<br>            method: &#39;put&#39;,<br>            url: `/bc-api/v2/orders/${orderId}`,<br>            data,<br>        });<br>    },<br><br>    deleteOrder(orderId) {<br>        return axios({<br>            method: &#39;delete&#39;,<br>            url: `/bc-api/v2/orders/${orderId}`,<br>        });<br>    },<br><br>    getResourceCollection(resource, params) {<br>        params = Object.assign({<br>            page: 1,<br>            limit: 10,<br>        }, params);<br><br>        return axios({<br>            method: &#39;get&#39;,<br>            url: `/bc-api/${resource}`,<br>            params,<br>        });<br>    },<br><br>    getResourceEntry(resource, params) {<br>        return axios({<br>            method: &#39;get&#39;,<br>            url: `/bc-api/${resource}`,<br>            params,<br>        });<br>    },<br><br>    updateResourceEntry(resource, data) {<br>        return axios({<br>            method: &#39;put&#39;,<br>            url: `/bc-api/${resource}`,<br>            data,<br>        });<br>    },<br><br>    deleteResourceEntry(resource, data) {<br>        return axios({<br>            method: &#39;delete&#39;,<br>            url: `/bc-api/${resource}`,<br>        });<br>    },<br>};</pre><h4>Create /resources/js/Services/index.js</h4><pre>import { ApiServices } from &#39;./ApiServices&#39;;<br><br>export {<br>    ApiService,<br>};</pre><h4>Let’s create two new components:</h4><p>Create /resources/js/components/Table.jsx that will contain a basic Table component, like below:</p><pre>import React from &#39;react&#39;;<br><br>export default class Table extends React.Component {<br>    constructor(props) {<br>        super(props);<br>    }<br><br>    getTableRow(data, index) {<br>        return (<br>            &lt;tr key={index}&gt;<br>                {this.props.tableHeaders.map(function (header, index) {<br>                    let value = data;<br>                    if (header.index) {<br>                        value = data[header.index];<br>                    }<br><br>                    if (header.callback) {<br>                        value = header.callback(value);<br>                    }<br><br>                    return &lt;td className=&quot;px-4 py-4 whitespace-nowrap&quot; key={index}&gt;{value}&lt;/td&gt;;<br>                })}<br>            &lt;/tr&gt;<br>        );<br>    }<br><br>    render() {<br>        return (<br>            &lt;table className=&quot;min-w-full divide-y divide-gray-200&quot;&gt;<br>                &lt;thead className=&quot;bg-gray-200&quot;&gt;<br>                    &lt;tr&gt;{this.props.tableHeaders.map(function (header, index) {<br>                        return &lt;th className=&quot;py-3.5 px-4 text-left&quot; key={index}&gt;{header.label}&lt;/th&gt;;<br>                    })}&lt;/tr&gt;<br>                &lt;/thead&gt;<br>                &lt;tbody className=&quot;bg-white divide-y divide-gray-200&quot;&gt;<br>                    {this.props.tableData.map(this.getTableRow.bind(this))}<br>                &lt;/tbody&gt;<br>            &lt;/table&gt;<br>        );<br>    }<br>}</pre><p>Create /resources/js/components/Spinner.jsx that will contain a basic Spinner component</p><pre>export default function Spinner() {<br>    return (<br>        &lt;div className=&quot;text-center&quot;&gt;<br>            &lt;div className=&quot;m-5&quot; role=&quot;status&quot;&gt;<br>                &lt;svg width=&quot;24&quot; height=&quot;24&quot; viewBox=&quot;0 0 24 24&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;&lt;path d=&quot;M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z&quot; opacity=&quot;.25&quot; /&gt;&lt;circle cx=&quot;12&quot; cy=&quot;2.5&quot; r=&quot;1.5&quot;&gt;&lt;animateTransform attributeName=&quot;transform&quot; type=&quot;rotate&quot; dur=&quot;0.75s&quot; values=&quot;0 12 12;360 12 12&quot; repeatCount=&quot;indefinite&quot; /&gt;&lt;/circle&gt;&lt;/svg&gt;<br>                &lt;span className=&quot;sr-only&quot;&gt;Loading...&lt;/span&gt;<br>            &lt;/div&gt;<br>        &lt;/div&gt;<br>    );<br>}</pre><p>Now, with the API service and components in place, the screens can be updated to produce something functional. To bring it all together, change the following files:</p><p>/resources/js/Pages/Home.jsx</p><pre>import Navigation from &#39;@/Components/Navigation&#39;;<br>import Spinner from &#39;@/Components/Spinner&#39;;<br>import { ApiService } from &#39;@/Services&#39;;<br><br>import { Head } from &#39;@inertiajs/react&#39;;<br>import React from &#39;react&#39;;<br><br>export default class Home extends React.Component {<br>    constructor(props) {<br>        super(props);<br><br>        this.state = {<br>            isCatalogSummaryLoading: true,<br>            isStoreInfoLoading: true,<br>            catalogSummary: {},<br>            storeInfo: {},<br>        };<br>    }<br><br>    componentDidMount() {<br>        ApiService.getResourceEntry(&#39;v2/store&#39;).then(this.handleStoreInfoResponse.bind(this));<br>        ApiService.getResourceEntry(&#39;v3/catalog/summary&#39;).then(this.handleCatalogSummaryResponse.bind(this));<br>    }<br><br>    handleStoreInfoResponse(response) {<br>        this.setState({<br>            isStoreInfoLoading: false,<br>            storeInfo: response.data,<br>        });<br>    }<br><br>    handleCatalogSummaryResponse(response) {<br>        this.setState({<br>            isCatalogSummaryLoading: false,<br>            catalogSummary: response.data.data,<br>        });<br>    }<br><br>    render() {<br>        const fieldsInSummary = [<br>            {<br>                label: &quot;Variant Count&quot;,<br>                index: &quot;variant_count&quot;,<br>                format: &quot;number&quot;,<br>            },<br>            {<br>                label: &quot;Inventory Count&quot;,<br>                index: &quot;variant_count&quot;,<br>                format: &quot;number&quot;,<br>            },<br>            {<br>                label: &quot;Inventory Value&quot;,<br>                index: &quot;inventory_value&quot;,<br>                format: &quot;currency&quot;,<br>            },<br>        ];<br>        return (<br>            &lt;&gt;<br>                &lt;Head title=&quot;Home&quot; /&gt;<br>                &lt;Navigation /&gt;<br>                &lt;div className=&quot;container mx-auto p-5&quot;&gt;<br>                    &lt;div className=&quot;grid grid-cols-4 gap-4&quot;&gt;<br>                        &lt;div className=&quot;content col-span-3 grid-col-3 rounded bg-gray-100 shadow-lg p-4&quot;&gt;<br>                            &lt;h2 className=&quot;text-xl font-bold mb-6&quot;&gt;This is the Home Page.&lt;/h2&gt;<br>                            &lt;div className=&quot;grid grid-cols-3 gap-4&quot;&gt;<br>                                {fieldsInSummary.map(function (summaryItem, index) {<br>                                    return &lt;div className=&quot;max-w-sm rounded overflow-hidden shadow-lg px-6 py-4 bg-white&quot; key={index}&gt;<br>                                        &lt;h3 className=&quot;font-bold text-xl mb-2&quot;&gt;<br>                                            {summaryItem.label}<br>                                        &lt;/h3&gt;<br>                                        {<br>                                            this.state.isStoreInfoLoading<br>                                                ?<br>                                                &lt;Spinner /&gt;<br>                                                :<br>                                                &lt;span className=&quot;text-gray-700 text-base&quot;&gt;<br>                                                    {<br>                                                        summaryItem.format === &#39;currency&#39;<br>                                                            ?<br>                                                            new Intl.NumberFormat(undefined, { style: &#39;currency&#39;, currency: this.state.storeInfo.currency }).format(this.state.catalogSummary[summaryItem.index])<br>                                                            :<br>                                                            this.state.catalogSummary[summaryItem.index]<br>                                                <br>                                                    }<br>                                                &lt;/span&gt;<br>                                        }<br>                                    &lt;/div&gt;;<br>                                }.bind(this))}<br>                            &lt;/div&gt;<br>                        &lt;/div&gt;<br>                        &lt;div className=&quot;sidebar rounded bg-gray-100 shadow-lg p-4&quot;&gt;<br>                            &lt;h2 className=&quot;text-xl font-bold mb-6&quot;&gt;This is a Side Bar.&lt;/h2&gt;<br>                            {<br>                                this.state.isStoreInfoLoading<br>                                    ?<br>                                    &lt;Spinner /&gt;<br>                                    :<br>                                    &lt;section&gt;<br>                                        {<br>                                            this.state.storeInfo.logo.url<br>                                                ?<br>                                                &lt;img src={this.state.storeInfo.logo.url} className=&quot;img-fluid img-thumbnail rounded&quot; /&gt;<br>                                                :<br>                                                &lt;h5&gt;{this.state.storeInfo.name}&lt;/h5&gt;<br>                                        }<br><br>                                        &lt;ul&gt;<br>                                            &lt;li className=&quot;flex flex-row justify-between mb-1&quot;&gt;<br>                                                &lt;h3 className=&quot;font-bold&quot;&gt;Domain:&lt;/h3&gt;<br>                                                &lt;p className=&quot;&quot;&gt;{this.state.storeInfo.domain}&lt;/p&gt;<br>                                            &lt;/li&gt;<br>                                            &lt;li className=&quot;flex flex-row justify-between mb-1&quot;&gt;<br>                                                &lt;h3 className=&quot;font-bold&quot;&gt;Secure URL:&lt;/h3&gt;<br>                                                &lt;p className=&quot;&quot;&gt;{this.state.storeInfo.secure_url}&lt;/p&gt;<br>                                            &lt;/li&gt;<br>                                        &lt;/ul&gt;<br><br>                                    &lt;/section&gt;<br>                            }<br>                        &lt;/div&gt;<br>                    &lt;/div&gt;<br>                &lt;/div&gt;<br>            &lt;/&gt;<br>        );<br>    }<br>}</pre><p>/resources/js/Pages/List.jsx</p><pre>import Navigation from &#39;@/Components/Navigation&#39;;<br>import Spinner from &#39;@/Components/Spinner&#39;;<br>import Table from &#39;@/Components/Table&#39;;<br>import { ApiService } from &#39;@/Services&#39;;<br><br>import { Head } from &#39;@inertiajs/react&#39;;<br>import React from &#39;react&#39;;<br><br>export default class List extends React.Component {<br>    constructor(props) {<br>        super(props);<br><br>        this.state = {<br>            isOrdersLoading: true,<br>            orders: {<br>                data: [],<br>                pagination: {},<br>            },<br>            tableHeaders:<br>                [<br>                    {<br>                        label: &quot;Order ID&quot;,<br>                        index: &quot;id&quot;,<br>                        callback: function (orderId) {<br>                            return orderId;<br>                        },<br>                    },<br>                    {<br>                        label: &quot;Billing Name&quot;,<br>                        index: &quot;billing_address&quot;,<br>                        callback: function (billingAddress) {<br>                            return `${billingAddress.first_name} ${billingAddress.last_name}`;<br>                        },<br>                    },<br>                    {<br>                        label: &quot;Order Total&quot;,<br>                        index: &quot;total_inc_tax&quot;,<br>                        callback: function (orderTotal) {<br>                            return orderTotal;<br>                        },<br>                    },<br>                    {<br>                        label: &quot;Order Status&quot;,<br>                        callback: function (data) {<br>                            let badgeClass = &#39;badge badge-&#39;;<br>                            if (data.status_id === 5) {<br>                                badgeClass += &#39;danger&#39;;<br>                            } else if (data.status_id === 2 || data.status_id === 10) {<br>                                badgeClass += &#39;success&#39;;<br>                            } else {<br>                                badgeClass += &#39;light&#39;;<br>                            }<br><br>                            return (<br>                                &lt;span className={badgeClass}&gt;{data.status}&lt;/span&gt;<br>                            );<br>                        },<br>                    },<br>                    {<br>                        label: &quot;Actions&quot;,<br>                        callback: function (data) {<br>                            if (data.status_id !== 5) {<br>                                return (<br>                                    &lt;button type=&quot;button&quot; className=&quot;bg-red-600 hover:bg-red-700 text-white font-bold py-2 px-4 rounded&quot; onClick={(e) =&gt; this.cancelOrder(data.id, e)}&gt;Cancel&lt;/button&gt;<br>                                );<br>                            }<br>                        }.bind(this),<br>                    },<br>                ],<br>        };<br>    }<br><br>    componentWillMount() {<br>        this.loadOrders();<br>    }<br><br>    loadOrders() {<br>        ApiService.getOrders({<br>            limit: 5<br>        }).then(this.handleOrdersResponse.bind(this));<br>    }<br><br>    handleOrdersResponse(response) {<br>        this.setState({<br>            isOrdersLoading: false,<br>            orders: {<br>                data: response.data<br>            }<br>        });<br>    }<br><br>    cancelOrder(orderId) {<br>        const newOrderData = { status_id: 5 };<br><br>        this.setState({<br>            isOrdersLoading: true,<br>        });<br><br>        ApiService.updateOrder(orderId, newOrderData)<br>            .then(this.loadOrders.bind(this));<br>    }<br><br>    hasOrders() {<br>        return (this.state.orders.data.length &gt; 0);<br>    }<br><br>    render() {<br>        return (<br>           &lt;&gt;<br>                &lt;Head title=&quot;Order List&quot; /&gt;<br>                &lt;Navigation /&gt;<br>                &lt;div className=&quot;container mx-auto p-5&quot;&gt;<br>                    &lt;div className=&quot;content col-span-3 grid-col-3 rounded bg-gray-100 shadow-lg p-4&quot;&gt;<br>                        &lt;h2 className=&quot;text-xl font-bold mb-6&quot;&gt;List of Orders&lt;/h2&gt;<br>                            {<br>                                this.state.isOrdersLoading<br>                                    ?<br>                                    &lt;Spinner /&gt;<br>                                    :<br>                                    this.hasOrders()<br>                                        ?<br>                                        &lt;section&gt;<br>                                            &lt;Table tableHeaders={this.state.tableHeaders} tableData={this.state.orders.data} /&gt;<br>                                        &lt;/section&gt;<br>                                        :<br>                                        &lt;section&gt;<br>                                            &lt;div className=&quot;emptyTable&quot;&gt;No orders exist yet!&lt;/div&gt;<br>                                        &lt;/section&gt;<br>                            }<br>                    &lt;/div&gt;<br>                &lt;/div&gt;<br>            &lt;/&gt;<br>        );<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1g7HSVwnlZOjkX9GyM2KMw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CGs4_TNMCdY8tFKQpzX-Qg.png" /></figure><h3>What’s next?</h3><p>If you got this far, congrats! You have a great base to work on as you experiment with all the BigCommerce APIs.</p><p>To launch a real app, aside from hosting it on a server other than your dev box. You’ll still need to add some persistent storage for API credentials, storing the store and user info received from the OAuth token request during app installation so users can load the app after the initial session expires. Error handling, especially for failed requests to the API, should be handled and surfaced to the merchant. Adding tests once you get to a state you are reasonably happy with helps keep regressions at bay.</p><p>Questions, comments, concerns? <a href="https://twitter.com/BigCommerceDevs">Tweet at us</a> or <a href="/service/mailto:devrel@bigcommerce.com">send our DevRel team an email</a>!</p><h3>The Code</h3><p><a href="https://github.com/bigcommerce/laravel-react-sample-app/releases/tag/1.0">https://github.com/bigcommerce/laravel-react-sample-app/releases/tag/1.0</a></p><p>Now go build something amazing!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=711ceceb5006" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bigcommerce-developer-blog/building-a-bigcommerce-app-using-laravel-and-react-711ceceb5006">Building a BigCommerce App Using Laravel and React</a> was originally published in <a href="https://medium.com/bigcommerce-developer-blog">BigCommerce Developer Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>