Tagged: left sidebar, right sidebar, woocommerce
-
AuthorPosts
-
May 27, 2015 at 3:25 pm #450596
How do I access the Single Product Page for woocommerce? I think this is created automatically, but for some reason, the sidebar is pushed under the product instead of being to the right.
Thanks.
May 27, 2015 at 6:35 pm #450752Hey jenki!
The product sidebar will display on the left beneath the product images. If you want a right sidebar then try this out, http://kriesi.at/documentation/enfold/product-page-left-or-right-sidebar/.
Regards,
ElliottMay 29, 2015 at 5:28 pm #451716Thank you for pointing the post out.
However, I get an error when I add the functions suggested in the post:
Fatal error: Cannot redeclare avia_add_image_div() (previously declared in /home4/bellussi/public_html/wp-content/themes/enfold/config-woocommerce/config.php:1046)
May 30, 2015 at 8:27 am #451940Hey!
Unfortunately, that modification is no longer working. It presents too much layout complications. Try to add this to the functions.php:
# # wrap single product image in an extra div # function avia_add_image_div() { echo "<div class='single-product-main-image alpha'>"; } function avia_close_image_div() { echo "</div>"; } # # wrap single product summary in an extra div # function avia_add_summary_div() { echo "<div class='single-product-summary'>"; } function avia_close_summary_div() { echo "</div>"; //close out the summary get_sidebar(); } function avf_product_sidebar_layout_mod($layout){ if( is_single() )$layout = "sidebar_left"; return $layout; } add_action('init', 'ava_product_sidebar_mod'); function ava_product_sidebar_mod() { add_action( 'woocommerce_before_single_product_summary', 'avia_add_image_div', 2 ); add_action( 'woocommerce_before_single_product_summary', 'avia_close_image_div', 20 ); add_action( 'woocommerce_before_single_product_summary', 'avia_add_summary_div', 25 ); add_action( 'woocommerce_after_single_product_summary', 'avia_close_summary_div', 3 ); add_filter( 'avf_product_sidebar_layout', 'avf_product_sidebar_layout_mod', 5); }
Edit config-woocommerce > config.php file, look for this code:
$sidebar_setting = avia_layout_class( 'main' , false );
Replace it with:
$sidebar_setting = apply_filters( 'avf_product_sidebar_layout', avia_layout_class( 'main' , false ) );
After that, add this in the Quick CSS field.
.single-product .product { width: 68%; margin-left: 4%; clear: none; float: right; }
The sidebar should switch to the left.
Cheers!
IsmaelMay 30, 2015 at 11:43 am #451980hi Ismael,
thanks for the reply. Unfortunately, I get the exact same error. The error of course refers to the avia_add_image_div() function in config.php of config-woocommerce. I don’t see how the changes to $sidebar_settings as you suggested modifies this declaration.
Let me know.
PS. I actually want to put the sidebar on the right side of the single product page. However, right now I just want the sidebar issue to work without errors first. :-)
May 31, 2015 at 7:57 am #452197Hey!
Did you copy the code right from your email? Please compare it to the code above, see the difference. If I am not mistaken, you’ll see the single quote and quotes symbols converted to something else. The code works fine on our installation. If you want a right sidebar, just change this line:
.single-product .product { width: 68%; margin-left: 4%; clear: none; float: right; }
to this:
.single-product .product { width: 68%; margin-right: 4%; clear: none; float: left; }
And this code:
function avf_product_sidebar_layout_mod($layout){ if( is_single() )$layout = "sidebar_left"; return $layout; }
to this:
function avf_product_sidebar_layout_mod($layout){ if( is_single() )$layout = "sidebar_right"; return $layout; }
Regards,
IsmaelMay 31, 2015 at 12:56 pm #452240This reply has been marked as private.June 1, 2015 at 1:47 pm #452507Solved. Works.
Let me explain if someone wants to do the same:
I was using pluginception to create a custom plugin so I can manage my custom code. I’m not sure if this was the right way or not, but I prefer this to editing functions.php.
So I switched to Code Snippets which is really good actually. I added the code snippet to that and set it for fronted only. Solved everything.
Thanks.
June 1, 2015 at 1:57 pm #452516Last question which may interest some people:
I see the sidebar added is the widget called “Sidebar Pages” but this a sidebar I already use for non-commerce pages specifically.
I see there is already a sidebar called “Single Product Pages” and I prefer to use that one so I can personalise the sidebar elements I use for single products only.
Thanks.
June 3, 2015 at 8:34 am #453604Hey!
Hello,
if you want to chnge the sidebar that will be displayed, you can use a sidebar conditional plugin, to select which sidebar will be visible to which page.
Is that solving your issue?
Best regards,
BasilisJune 3, 2015 at 12:42 pm #453705Not at all Basilis.
If you follow the thread, you will see that the sidebar was move to the right of the single product page fro under it.
Before when it was under the product image (I think a bug as there are many posts about it) the sidebar was defined as Single Product Page widget, correct? And it worked fine.
the code by Ismael above fixes the sidebar and moves it right but it also changes the sidebar from Single Product Page to Sidebar Page.
The question is: how can the code by Ismael be changed so that the correct default sidebar is used, Single Product Page?
Thanks
- This reply was modified 9 years, 6 months ago by jenki. Reason: Fixed bold css
June 6, 2015 at 12:01 pm #455444Hey!
The sidebar.php file checks what page is currently being viewed then serve the sidebar accordingly. Look for this line:
function avia_close_summary_div() { echo "</div>"; //close out the summary get_sidebar(); }
Replace it with:
function avia_close_summary_div() { global $avia_config; echo "</div>"; //close out the summary $avia_config['currently_viewing'] = "shop_single"; get_sidebar(); }
Cheers!
Ismael- This reply was modified 9 years, 6 months ago by Ismael.
June 13, 2015 at 10:48 am #458730Perfect! Solved.
Thanks
-
AuthorPosts
- The topic ‘Single Product Page is strange: sidebar appears UNDER product’ is closed to new replies.