How to Create a Product Page - P2 - Meta Box + Oxygen
Tags: metabox, product, tutorial, oxygen
Published: 2022-09-13 04:40:50

For an e-commerce website, a product page is considered the most essential page. If this page is full of information and beautifully presented, it'll attract many customers and direct them to purchase quickly.

Technically, there are many ways to build a product page. We’ve had <a href="https://metabox.io/create-product-pages/">a tutorial</a> on doing it with Meta Box only. In this post and the next one of this series, we’ll dig in how to do it with page builders.

<!--more-->

I also take a car rental page built with Oxygen as an example in this tutorial.

<img class="aligncenter" src="https://i.imgur.com/Z8h2iDS.png" alt="Example of a Product page" width="1000" height="562" />
<h2>Video Version</h2>
https://youtu.be/9P2Q49n8sJk
<h2>Before Getting Started</h2>
The product is a kind of custom post type. In this case, each car for the rental will be a post in that post type. Besides the default information such as title and content of the post, we’ll need some extra information about the cars such as price, image gallery, type of fuel, etc. So, we use custom fields to save that information.

<img class="aligncenter" src="https://i.imgur.com/KT6xDPo.png" alt="The extra information will be saved in custom fields" width="1006" height="562" />

To create a custom post type and custom fields, we use the <a href="https://wordpress.org/plugins/meta-box/">Meta Box core plugin</a>. It’s free and available on <a href="https://wordpress.org/plugins/meta-box/">wordpress.org</a>.

We also need some Meta Box extensions for more advanced features. You can use <strong>Meta Box AIO</strong> or install the following extensions individually:
<ul>
 	<li><a href="https://metabox.io/plugins/custom-post-type/">MB Custom Post Type</a>: to create custom post types.</li>
 	<li><a href="https://metabox.io/plugins/meta-box-builder/">Meta Box Builder</a>: to have a UI on the back end to create custom fields easily.</li>
</ul>
Don’t forget that we’ll build the page using <strong>Oxygen</strong>. You should use the 3.9 version or upper, which has had the native integration with Meta Box already.
<h2>Step 1: Create a New Custom Post Type</h2>
Go to <strong>Meta Box</strong> &gt; <strong>Post Types</strong> &gt; <strong>New Post Type</strong> to create a new custom post type for the product.

<img class="aligncenter" src="https://i.imgur.com/ZGSNOek.png" alt="create new custom post type" width="1000" height="609" />
<h2>Step 2: Create Custom Fields</h2>
Go to <strong>Meta Box</strong> &gt; <strong>Custom Fields</strong>, then create fields as you want.

<img class="aligncenter" src="https://i.imgur.com/akw8HU0.png" alt="create new custom fields" width="1000" height="730" />

In this tutorial, I just take a typical example of car rental with some common fields. They are all quite basic fields with no special configuration.

<img class="aligncenter" src="https://i.imgur.com/yRLXjpI.png" alt="example of car rental with some common fields" width="1000" height="816" />

Next, move to the <strong>Settings tab</strong> &gt; <strong>Location</strong> &gt; choose <strong>Post Type</strong> as <strong>Car Rental</strong> to apply these fields to this post type.

<img class="aligncenter" src="https://i.imgur.com/Q3YdpN5.png" alt="Settings tab &gt; Location &gt; choose Post Type as Car Rental" width="1000" height="689" />

Back to the post editor, you will see all of the newly created custom fields.

<img class="aligncenter" src="https://i.imgur.com/gkVJ6Vx.png" alt="newly created custom fields." width="1002" height="830" />
<h2>Step 3: Create a Template with Oxygen</h2>
Go to the <strong>Oxygen</strong> menu and choose to create a new template.

In the settings of the template, choose a design that you want the template to inherit from, then choose your post type in the <strong>Singular</strong> section to apply the template to it.

<img class="aligncenter" src="https://i.imgur.com/ZEyhb85.png" alt="Choose the design for the template you wants to display" width="1000" height="769" />

Move to the post editor and create a new post in the newly created post type. Pay attention that we can see the template is already rendered for this product page.

<img class="aligncenter" src="https://i.imgur.com/CTQREhu.png" alt="Move to the post editor and create a new post in the newly created post type" width="999" height="828" />

After filling in the information for the product, let’s edit the template.

First, select a <strong>Section</strong> component to contain all of the product information.

<img class="aligncenter" src="https://i.imgur.com/ppnWLhx.png" alt="select a Section component to contain all of the product information." width="1000" height="822" />

If you want to set columns for the content as below, let’s add a <strong>Column</strong> component.

<img class="aligncenter" src="https://i.imgur.com/6pDhCvc.png" alt="split the content into columns" />

<img class="aligncenter" src="https://i.imgur.com/ywHmHod.png" alt="add the column component" />

Just set the <strong>Column</strong> <strong>Layout</strong> as you want.

In this Column component, there’ll be 2 <strong>div</strong> tags available, equivalent to 2 columns. In the first <strong>div</strong> tag, select the <strong>Carousel Builder</strong> component to display the image gallery as a slider.

Choose <strong>Meta Box</strong> gallery in the <strong>Carousel</strong> <strong>content</strong> section, and fill in the ID of the gallery field in the <strong>Meta Box image field</strong> section. Then, all the images saved in that field will be displayed.

<img class="aligncenter" src="https://i.imgur.com/eyUWeFG.png" alt="set the gallery" />

You can move to the <strong>Advanced</strong> tab to set the slider display as you want.

Move to the second column with the 2nd div tag. To get the title of the post, means the name of the product, add a <strong>Heading</strong> component. Then, insert data from the post title to this component.

<img class="aligncenter" src="https://i.imgur.com/MZf00m2.gif" alt="insert data from the title of the post" />

For the product description, choose the <strong>Text</strong> component and connect it with the content of the post.

Also, choose the <strong>Text</strong> component for the price of the product. The pricing includes the currency, so you can type some text and symbols in this component to get the right format, then insert data from the field.

<img class="aligncenter" src="https://i.imgur.com/IQTqdXh.gif" alt="display the price of product" />

For all of this section, I’ll add a <strong>div</strong> component.

<img class="aligncenter" src="https://i.imgur.com/gFiYiBt.png" alt="add a div component" />

For each row in this section, I also use a <strong>div</strong> component.

<img class="aligncenter" src="https://i.imgur.com/kYAEy6C.png" alt=" Create a div to hold a row's information" width="1000" height="562" />

<img class="aligncenter" src="https://i.imgur.com/ZTE6rQr.png" alt="div tag for section and div tag for section to cover all the information." width="1000" height="561" />

In the <strong>div</strong> for a row, choose the <strong>Heading</strong> component and name it as the name of the characteristic. Then, add a <strong>Text</strong> component, and connect it to the field which saves the corresponding data to the characteristic. Last one, style these two components and the div that covers them in your own way.

For the remaining characteristics, just clone this <strong>div</strong>, which is used for a row by duplicating. Then, just change the headings and link the <strong>Text</strong> components to the right fields.

We’ve finished getting all of the information about the product and displayed them on the product page. You can style them as you want. After styling, I got this one.

<img class="aligncenter" src="https://i.imgur.com/Z8h2iDS.png" alt="The product page when we finished creating it" width="1000" height="562" />
<h2>Last Words</h2>
It seems to be so easy to create a product page with Meta Box and Oxygen, right? With custom fields, you can easily save extra information about products and display them in a more beautiful style on the product page. Let’s try and share the result with us in the comments.

Don’t forget to follow our channel to see other ways to use other page builders!