Woocommerce integration

How can I check page type like woocommerce shop, product, checkbox, etc?
I want to check page type by the route that the user goes and after that rendered page what needs.

Hi @ivaskivroman1024

Welcome to the community.

You could check the value of state.router.link in the theme’s index.html file and render the required component, like this:

<Main>
   <Switch>
       <Loading when={data.isFetching} />
       <List when={data.isArchive} />
       <ShopPage when={state.router.link=='/shop/'} />
       <Post when={data.isPostType} />
       <PageError when={data.isError} />
    </Switch>
</Main>

Just to add some context regarding the development of WooCommerce projects using Frontity…

Frontity doesn’t provide an official package to connect with WooCommerce yet (or indeed any other E-Commerce solution that works with WordPress). This is something we are really interested in working on but it may take a while until we do (because of some other priorities in our roadmap).

However, you can still integrate WooCommerce yourself, just as you would do in a NextJS or Gatsby app, using whatever tools you prefer on top of Frontity and React.

Some members of the community have already tried WooCommerce in their Frontity projects, here you have some forum threads that might be useful → https://community.frontity.org/tag/woocommerce.

In addition, this is another good article on creating a React front end for WooCommerce that may help you with your project: https://www.joshuaiz.com/words/no-woocommerce-cart-api-no-problem.

Be careful with those state.router.link === "/shop/" statements. If you visit /shop/?utm_campaign=sale-2020 it won’t work. At least you should do state.router.link.startsWith("/shop/") although it would be better to add /shop/ to state.source.data:

const state = {
  source: {
    data: {
      "/shop/": {
        isReady: true,
        isFetching: false,
        isShop: true,
      },
    },
  },
};

And then check for data.isShop.

I have just noticed that the WooCommerce team is working on an official public REST API!! :tada::tada::tada::tada:

It’s not production-ready yet, but it will be at some point.

This is great news because we can build the official Frontity WooCommerce package on top of that in the same way we built wp-source on top of the official REST API.

7 Likes

@luisherranz great to hear you are planning to develop an official WooCommerce integration with Frontity. Can’t wait to see this happen. :nerd_face:

1 Like

How will this compare to this: https://cocart.xyz/

1 Like

I think they are going to be similar, although the WooCommerce ones will be the official one. I have asked the WooCommerce team about their plans for this Store API. Let’s see what they say :slight_smile:

1 Like

Have you heard back from the WooCommerce team yet?

Oh, yes, sorry. I forgot to update this thread, thanks for the reminder! :smile:

It seems like they can’t commit to a v1.0 of the Store API yet, but they are actively working on that for their Gutenberg Blocks. Everything indicates at this point that they will keep doing so until the Store API covers all the funcionalities.

So we want to do a proof of concept with the Store API to see if that would be a path we could take if they finally commit to making it official :slightly_smiling_face:

1 Like

WooCommerce still has long way to go to support the ability to be decoupled for both registered and guest customers. I have worked out most of the requirements in CoCart to provide the support needed. I’m always open to improvements and always providing them asap.

2 Likes