- This topic has 7 replies, 2 voices, and was last updated 3 years, 4 months ago by
David.
-
AuthorPosts
-
December 1, 2022 at 8:13 am #2444684
Mirko
Hello,
Is it possible to have 3 columns on the single page product with Woocommerce?
I would like to have in order: product image / description / other details (hooks) and cart button.Thanks!
December 1, 2022 at 8:59 am #2444783David
StaffCustomer SupportHi there,
not sure, it would probably take custom development.
Do you have a shop set up with the content you want displayed on the single product ? If so can i see it and ill take a look at its easy enough for us to assist with.December 1, 2022 at 9:13 am #2444809Mirko
Hello,
So I provide you an example of a single product that i would like to have with the 3 columns layout.
The link is on the private information tab.December 1, 2022 at 9:39 am #2444938David
StaffCustomer SupportAnd for Mobile – i assume the current layout is correct ?
December 1, 2022 at 10:28 am #2445159Mirko
Exactly for Mobile i will stick to the vertical configuration.
December 1, 2022 at 11:05 am #2445279David
StaffCustomer SupportOk, so we can add some HTML into the template. To create our 2 column
<div>s.
And we can use the Hooks that Woo provides in the single post. Specifically thewoocommerce_single_product_summaryhook.See here:
You can see there are already a lot of templates callbacks made from that hook.
For example thewoocommerce_template_single_titleis hooked in with priority of5
And thewoocommerce_template_single_add_to_cartis hooked in with a priorty of30So we can hook in before and after those with this PHP Snippet:
// hook in open left column div at 1 before all other callbacks add_action('woocommerce_single_product_summary',function(){ ?> <!-- open summary-left-column --> <div class="summary-left-column"> <?php },1); // hook in closing left column div at 25 before the cart form add_action('woocommerce_single_product_summary',function(){ ?> <!-- close summary-left-column --> </div> <?php },25); // open right hand column div at 26 just after our left column div and the cart form add_action('woocommerce_single_product_summary',function(){ ?> <!-- open summary-right-column --> <div class="summary-right-column"> <?php },26); // close our right hand column div at end of summary add_action('woocommerce_single_product_summary',function(){ ?> <!-- close summary-right-column --> </div> <?php },1000);this will add your 2 columns around the content.
If you’re hooking other content into the same hook, then you just need to consider its priority.
Lower than25for left column
Greater than26for right columnAnd you can make them side by side with some CSS:
@media(min-width: 769px) { .woocommerce-page div.product div.summary { display: grid; grid-template-columns: 1fr 1fr; grid-gap: 20px } }December 2, 2022 at 9:17 am #2446980Mirko
That’s perfect!
I will change the columns width but the logic is perfect.
Thank again for your support!December 3, 2022 at 5:39 am #2447819David
StaffCustomer SupportGlad to be of help
-
AuthorPosts
- You must be logged in to reply to this topic.