I just installed Woocommerce plugin on my WordPress site and create my own custom theme. My theme structure should be like this:
.
├── index.php
├── style.css
├── functions.php
Now, when I tried to access, /cart
route, it still load blank page (which i presume my homepage), and I can’t load Woocommerce template that resides in ~/wp-content/plugins/woocommerce/template/cart/
. I’ve read the docs here, but it only explains about template overriding.
Now, how do I load ~/wp-content/plugins/woocommerce/template/cart/
template, when i access /cart
route on my site ?
I also tried to change my cart page attribute template on dashboard->pages->cart
, but i can only set it as default template
with no other options.
2
Answers
What you have so far is the basic wp custom theme structure.
In order to add Woocommerce support to your theme add this function to your
functions.php
fileThen if you want to have a custom cart page for example and not the default Woocommerce cart layout you have to add a folder Woocommerce in your theme root folder and and as a subfolder the part you want to override form the Woocommerce plugin template file.
WordPress custom theme structure with Woocommerce support:
If you are looking to use the default WooCommerce cart page, you will have to add what is called a ‘shortcode’ into one of your pages. The WordPress editor will do the rest to set up the page and its functionality.
For the cart page, all you have to do is add a this text somewhere on the page that you would like to act as the cart:
[woocommerce_cart]
.If you would also like to use a checkout page, the shortcode for that is
[woocommerce_checkout]
.If you do either of these, you will also want to change the WooCommerce plugin’s default cart and checkout pages to your pages. This can be done in ‘Dashboard > WooCommerce > Settings > Advanced’ under the ‘Page setup’ header.
This page may be a helpful resource if you have continued interest in using WooCommerce shortcodes in your site: https://docs.woocommerce.com/document/woocommerce-shortcodes/.