I want to remove the thumbnails from the gallery (flexslider) of the product single page.
But I want to keep the arrow for the previous/next images (in case there is more than 1 image).
I found the following code:
add_action( 'woocommerce_product_thumbnails', 'enable_gallery_for_multiple_thumbnails_only', 5 );
function enable_gallery_for_multiple_thumbnails_only() {
global $product;
if( ! is_a($product, 'WC_Product') ) {
$product = wc_get_product( get_the_id() );
}
if( empty( $product->get_gallery_image_ids() ) ) {
remove_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );
}
}
Source: https://stackoverflow.com/a/56238267/1788961
The problem is, that the function removes the thumbnail and the arrows.
Is there any way to keep the arrows?
And I know, that I could use display:none or maybe change the template file.
But I'm searching a solution with an own function.
if you want keep only arrow then you just put this code in functions.php:
// for arrow on single product page slide
add_filter( 'woocommerce_single_product_carousel_options', 'sf_update_woo_flexslider_options' );
/**
* Filer WooCommerce Flexslider options - Add Navigation Arrows
*/
function sf_update_woo_flexslider_options( $options ) {
$options['directionNav'] = true;
return $options;
}
And this code put it in your theme style.css file:
/*add for arrow on main image slide*/
ul.flex-direction-nav {
position: absolute;
top: 30%;
z-index: 99999;
width: 100%;
left: 0;
margin: 0;
padding: 0px;
list-style: none;
}
li.flex-nav-prev {float: left;}
li.flex-nav-next {float: right;}
a.flex-next {visibility:hidden;}
a.flex-prev {visibility:hidden;}
a.flex-next::after {
visibility:visible;content: '\f054';
font-family: 'Font Awesome 5 Free';
margin-right: 10px;
font-size: 20px;
font-weight: bold;
}
a.flex-prev::before {
visibility:visible;
content: '\f053';
font-family: 'Font Awesome 5 Free';
margin-left: 10px;
font-size: 20px;
font-weight: bold;
}
ul.flex-direction-nav li a {
color: black;
}
ul.flex-direction-nav li a:hover {
text-decoration: none;
}
.flex-control-nav .flex-control-thumbs{
display: none;
}
add_filter( 'woocommerce_single_product_carousel_options', 'sf_update_woo_flexslider_options' );
/**
* Filer WooCommerce Flexslider options - Add Navigation Arrows
*/
function sf_update_woo_flexslider_options( $options ) {
$options['directionNav'] = true;
$options['controlNav'] = false;
return $options;
}
The given approved answer is close but still resorts to CSS to hide the thumbnails.
You can disable controlNav directly on the same filter you use to show the arrows.
Related
I wanted to add a 'Free UK Delivery' text badge to products that do not have a shipping class associated with them. This is the very rough code I have so far but this is a new language to me and I'm trying to splice things together and not succeeding very well. Would super appreciate some help:
add_action( 'woocommerce_before_shop_loop_item_title', 'single_product_label', 10 );
function single_product_label() {
global $product;
if( $shipping_class = $product->get_shipping_class() ) {
if ( $shipping_class->is_wp_error) {
echo '<span class="freedel">Free UK Delivery</span>';
}
}
return '';
}
and CSS code:
.freedel {
padding: 3px 8px;
text-align: center;
background: #222;
color: white;
font-weight: bold;
position: absolute;
top: 6px;
right: 6px;
font-size: 12px;
}
Thanks in advance,
Emma
Your code has errors in it. You can change it to the following
add_action( 'woocommerce_before_shop_loop_item_title', 'single_product_label', 10 );
function single_product_label() {
global $product;
if ( empty( $product->get_shipping_class() ) ) {
echo '<span class="freedel">Free UK Delivery</span>';
}
}
I have done a quick check and this shows the label. See the screenshot attached.
i using Wordpress button plugin called Max Buttons to generate button as i want. But in that button creation into URL where need to point button have only URL where need to point button. This looks like this:
So as you can see, i use URL link to autoupdate coupon code to product and redirect to checkout.. But, that is for static product ID. So my question is how to generate that to each product , to autoget product ID at end of URL? MaxButton plugin generate shortcode where i inserting into place where i want.
Current URL is:
https://testsite/checkout/?apply_coupon=5%off&fill_cart=4004
How to get that fill_cart=PRODUCT_ID to be dynamic?
Updated (for simple and variable products, using jQuery)
You can build a custom shortcode like Max buttons with 3 arguments (attributes):
class (the css class of the button)
coupon (the coupon code that will be added in the url)
text (the button text)
1) The code (The CSS styles are embedded in the 1st function. The jQuery code is in the footer):
add_shortcode('max_btn', 'custom_dynamic_max_button');
function custom_dynamic_max_button( $atts ) {
if( ! is_product() ) return; // exit
global $post;
// Shortcode attributes
$atts = shortcode_atts(
array(
'class' => '',
'coupon' => '',
'text' => '',
),
$atts, 'max_btn');
// Formatting CSS class
$class = ! empty($atts['class']) ? 'max-btn ' . $atts['class'] : 'max-btn';
// Format the coupon code if it's set as an argument
$coupon = ! empty($atts['coupon']) ? 'apply_coupon=' . $atts['coupon'] . '&' : '';
// Format the url with the dynamic Product ID
$link = wc_get_checkout_url() . '?' . $coupon . 'fill_cart=' . $post->ID;
// The button code:
ob_start();
?>
<style>
.max-btn.flash-btn {
position: relative;
text-decoration: none;
display: inline-block;
vertical-align: middle;
border-color: #ef2409;
width: 225px;
height: 43px;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-style: solid;
border-width: 2px;
background-color: rgba(239, 36, 9, 1);
-webkit-box-shadow: 0px 0px 2px 0px #333;
-moz-box-shadow: 0px 0px 2px 0px #333;
box-shadow: 0px 0px 2px 0px #333;
color: #c8146e;
}
.max-btn.flash-btn {
animation-name: flash;
animation-duration: 1s;
animation-timing-function: linear;
animation-iteration-count: infinite;
-webkit-animation-name: flash;
-webkit-animation-duration: 1s;
-webkit-animation-timing-function: linear;
-webkit-animation-iteration-count: infinite;
-moz-animation-name: flash;
-moz-animation-duration: 1s;
-moz-animation-timing-function: linear;
-moz-animation-iteration-count: infinite;
}
.max-btn:hover.flash-btn {
border-color: #505ac7;
background-color: rgba(255, 255, 255, 1);
-webkit-box-shadow: 0px 0px 2px 0px #333;
-moz-box-shadow: 0px 0px 2px 0px #333;
box-shadow: 0px 0px 2px 0px #333;
}
#keyframes flash {
0% { opacity: 1.0; }
50% { opacity: 0.5; }
100% { opacity: 1.0; }
}
#-moz-keyframes flash {
0% { opacity: 1.0; }
50% { opacity: 0.5; }
100% { opacity: 1.0; }
}
.max-btn.flash-btn > .mb-text {
color: #fff;
font-family: Tahoma;
font-size: 20px;
text-align: center;
font-style: normal;
font-weight: bold;
padding-top: 11px;
padding-right: 0px;
padding-bottom: 0px;
padding-left: 0px;
line-height: 1em;
box-sizing: border-box;
display: block;
background-color: unset;
outline: none;
}
.max-btn:hover.flash-btn > .mb-text {
color: #505ac7;
}
.max-btn.disabled,
.max-btn:hover.disabled {
cursor: not-allowed;
background-color: rgba(160, 160, 160, 1) !important;
border-color: rgba(160, 160, 160, 1) !important;
animation-name: unflash !important;
-webkit-animation-name: unflash !important;
-moz-animation-name: unflash !important;
}
.max-btn:hover.flash-btn.disabled > .mb-text {
color: #fff !important;
}
</style>
<a class="<?php echo $class; ?>" href="<?php echo $link; ?>">
<span class="mb-text"><?php echo $atts['text']; ?></span>
</a>
<input type="hidden" class="ccoupon" name="ccoupon" value="<?php echo $atts['coupon']; ?>">
<?php
return ob_get_clean(); // Output
}
add_action('wp_footer','custom_jquery_single_product_script');
function custom_jquery_single_product_script(){
// Only for single product pages
if ( ! is_product() ) return;
// Get an instance of the WC_Product object
$product = wc_get_product(get_the_id());
// Only for variable products
if( ! $product->is_type('variable') ) return;
// Pass the partial link to jQuery
$partial_link = wc_get_checkout_url() . '?';
?>
<script type="text/javascript">
(function($){
// variables initialization
var a = '<?php echo $partial_link; ?>',
b = 'input[name="variation_id"]',
c = 'a.max-btn.flash-btn',
d = '.variations select',
e = 'input.ccoupon';
// Get the partial link (without the product ID)
if( $(e).val() != '' )
a += 'apply_coupon=' + $(e).val() + '&fill_cart=';
else
a += 'fill_cart=';
// Utility function to enable button with the correct variation ID
function enableButton(){
// Set the correct URL with the dynamic variation ID and remove "disable" class
$(c).attr("href", a+$(b).val()).removeClass('disabled');
}
// Utility function to disable button
function disableButton(){
// Remove href attribute and set "disable" class
$(c).removeAttr('href').addClass('disabled');
}
// -- 1. Once DOM is loaded
// Remove href attribute and set "disable" class
disableButton();
// If variation ID exist, we enable the button with the correct variation ID
setTimeout(function(){
if($(b).val() > 0)
enableButton();
}, 800);
// -- 2. On live events
// On product attribute select fields "blur" event
$(d).blur( function(){
// If variation ID exist (all product attributes are selected)
if( $(b).val() > 0 )
enableButton();
// If variation ID doesn't exist (all product attributes are NOT selected)
else
disableButton();
console.log('select: '+$(b).val());
});
})(jQuery);
</script>
<?php
}
Code goes in function.php file of your active child theme (or active theme).
2) Possible shortcode USAGE:
In the product Wordpress post, custom post or page editor:
[max_btn class="flash-btn" coupon="5%off" text="Buy Now Get 5% off"]
In a php file, template or function:
echo do_shortcode('[max_btn class="flash-btn" coupon="5%off" text="Buy Now Get 5% off"]');
Or (inside html):
<?php echo do_shortcode('[max_btn class="flash-btn" coupon="5%off" text="Buy Now Get 5% off"]'); ?>
The generated html code will be something like (and it works for variable products too):
<a class="max-btn flash-btn" href="http://www.example.com/checkout/?apply_coupon=5%off&fill_cart=37">
<span class="mb-text">Buy Now Get 5% off</span>
</a>
<input type="hidden" class="ccoupon" name="ccoupon" value="5%off">
The Url will be auto generated with a dynamic product ID on single product pages. Tested and works.
For variable products:
When all the product attributes are not selected and the variation ID is not set, the button is disabled:
When all the product attributes are selected and the variation ID is set, the button is enabled and blink:
Woocommerce comes with a default product filter widget, located in
/wp-content/plugins/woocommerce/includes/widgets/class-wc-widget-layered-nav-filters.php
I have a lot of products/categories etc and using this looks very messy. I have tried to tidy it up and turn it into an accordion menu which seems to work as can be seen from code at bottom.
I am struggling, however, to add it into my theme.
I have created my own widget using:
<?php>
class Custom_WC_Widget_Layered_Nav extends WC_Widget_Layered_Nav {
Public function widget( $args, $instance ) {
//taken details prom default plugin and inserted here
}
?>
<script>
var acc = document.getElementsByClassName("widget-title");
var i;
for (i = 0; i < acc.length; i++) {
acc[i].onclick = function() {
this.classList.toggle("active");
var panel = this.nextElementSibling;
if (panel.style.maxHeight){
panel.style.maxHeight = null;
} else {
panel.style.maxHeight = panel.scrollHeight + "px";
}
}
}
</script>
I have saved this in:
/wp-content/themes/my-theme/woocommerce/includes/widgets/custom-wc-widget-layered-nav.php
I then added the following code into functions.php:
add_action( 'widgets_init', 'err_override_woocommerce_widgets', 15 );
function err_override_woocommerce_widgets() {
if ( class_exists( 'WC_Widget_Layered_Nav' ) ) {
unregister_widget( 'WC_Widget_Layered_Nav' );
include_once( 'wp-content/themes/my-theme/woocommerce/includes/widgets/custom-wc-widget-layered-nav.php' );
register_widget( 'Custom_WC_Widget_Layered_Nav' );
}
}
The new code in the functions.php seems to give errors:
Fatal error: Class 'Custom_WC_Widget_Layered_Nav' not found in /homepages/8/d692312546/htdocs/Mytheme/wp-includes/class-wp-widget-factory.php on line 106
Is there anything I can change to avoid this error?
as you can see below, the coding seems to work and have desired affect.
var acc = document.getElementsByClassName("widget-title");
var i;
for (i = 0; i < acc.length; i++) {
acc[i].onclick = function() {
this.classList.toggle("active");
var panel = this.nextElementSibling;
if (panel.style.maxHeight){
panel.style.maxHeight = null;
} else {
panel.style.maxHeight = panel.scrollHeight + "px";
}
}
}
h1.widget-title {
background-color: #eee;
color: #444;
cursor: pointer;
padding: 5px;
width: 100%;
text-align: left;
border: none;
outline: none;
transition: 0.4s;
margin-top:5px;
}
/* Add a background color to the button if it is clicked on (add the .active class with JS), and when you move the mouse over it (hover) */
h1.widget-title.active, h1.widget-title:hover {
background-color: #ccc;
}
/* Style the accordion panel. Note: hidden by default */
aside>ul {
padding: 0 18px;
background-color: white;
max-height: 0;
overflow: hidden;
transition: max-height 0.2s ease-out;
}
h1.widget-title:after {
content: '\02795'; /* Unicode character for "plus" sign (+) */
font-size: 13px;
color: #777;
float: right;
margin-left: 5px;
}
h1.widget-title.active:after {
content: "\2796"; /* Unicode character for "minus" sign (-) */
}
#secondary .widget {
font-size: 0.86em;
}
.widget-area > aside {
background: white;
border: 1px solid #ededed;
border-radius: 6px;
padding: 5px 20px;
margin-bottom: 5px;
width:20em
}
.widget-title {
font-size: 1.43em;
}
<div class="widget-area" id="secondary" role="complementary">
<aside class="widget woocommerce widget_layered_nav" id="Woocommerce-layered-nav-1">
<h1 class="widget-title">Title1</h1>
<ul>
<li class="layered-nav-term">
nav term
<span class="count">(10)</span>
</li>
</ul>
</aside>
<aside class="widget woocommerce widget_layered_nav" id="Woocommerce-layered-nav-2">
<h1 class="widget-title">Title2</h1>
<ul>
<li class="layered-nav-term">
nav term2
<span class="count">(10)</span>
</li>
</ul>
</aside>
</div>
According to this article
you have to change the path according to where you saved this widget:
add_action( 'widgets_init', 'err_override_woocommerce_widgets', 15 );
function err_override_woocommerce_widgets() {
// Ensure our parent class exists to avoid fatal error (thanks Wilgert!)
if ( class_exists( 'WC_Widget_Layered_Nav' ) ) {
unregister_widget( 'WC_Widget_Layered_Nav' );
include_once( 'woocommerce/includes/widgets/custom-wc-widget-layered-nav.php' );
register_widget( 'Custom_WC_Widget_Layered_Nav' );
}
}
Hope it works!
UPDATE:
What comes in mind is first save the script inside your js folder and name it something like custom.js then you have to register that script as follow:
// Register your assets during `wp_enqueue_scripts` hook inside `functions.php`.
function custom_register_scripts() {
// Give the path of the script
wp_register_script('js-custom', 'path/to/js/custom.js',array('jquery'));
}
then you can enqueue your script into where your widget is.
public function widget( $args, $instance ) {
// Enqueue needed assets inside the `widget` function.
wp_enqueue_script('js-custom');
// Output widget contents.
}
My WordPress theme ("Function") uses an ugly "progress bar" style ratings system which overrides the default WooCommerce star-ratings. See below:
http://demo.woothemes.com/function/shop/castillo-cap/#tab-reviews
For the life of me I can't figure out how remove this and replace it with the default/original WooCommerce star-ratings, the ones that actually look like stars (font awesome I believe?)
I believe what needs to be done is to somehow overwrite or prioritize WooCommerce star-ratings css over the theme's. Ultimately I would like for all of the progress bars (shop page & individual product pages, review submission forms) to be replaced with the default WordPress stars, however at the moment I can settle for just the shop page where the ratings (progress bars) appear under the product's photos
I was able to find the css code controlling (creating?) the progress bars in Function->Includes->Integrations->woocommerce->css->woocommerce.css However, I also found some suspicious looking code in woocommerce.less located in the same css folder.
Here is code I found in woocommerce.css:
star-rating {
width: 80px;
height: 1em;
background: #eaeaea;
-webkit-border-radius: 3.631em;
border-radius: 3.631em;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
clear: both;
}
.star-rating span {
background: #52a0cd;
height: 100%;
overflow: hidden;
float: left;
text-indent: -999em;
-webkit-box-sizing: border-box;
/* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box;
/* Firefox, other Gecko */
box-sizing: border-box;
/* Opera/IE 8+ */
-webkit-border-radius: 3.631em;
border-radius: 3.631em;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
}
.star-rating span span {
display: none;
}
p.stars {
overflow: hidden;
zoom: 1;
}
p.stars span {
width: 80px;
height: 16px;
position: relative;
float: left;
background: #eaeaea;
-webkit-border-radius: 3.631em;
border-radius: 3.631em;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
}
p.stars span a {
float: left;
position: absolute;
left: 0;
top: 0;
width: 16px;
height: 0;
padding-top: 16px;
overflow: hidden;
}
p.stars span a:hover,
p.stars span a:focus {
background: #52a0cd;
-webkit-border-radius: 3.631em;
border-radius: 3.631em;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
}
p.stars span a.active {
background: #52a0cd;
-webkit-border-radius: 3.631em;
border-radius: 3.631em;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
}
p.stars span a.star-1 {
width: 16px;
z-index: 10;
-webkit-border-top-left-radius: 3.631em;
-webkit-border-bottom-left-radius: 3.631em;
border-top-left-radius: 3.631em;
border-bottom-left-radius: 3.631em;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
}
p.stars span a.star-2 {
width: 32px;
z-index: 9;
}
p.stars span a.star-3 {
width: 48px;
z-index: 8;
}
p.stars span a.star-4 {
width: 64px;
z-index: 7;
}
p.stars span a.star-5 {
width: 80px;
z-index: 6;
}
...and here is what I found in woocommerce.less:
// Single product
.single-product {
.summary {
.woocommerce-product-rating {
.clearfix;
.star-rating {
float: left;
margin: .327em 0 0;
}
.woocommerce-review-link {
float: right;
display: block;
}
}
// General WooCommerce
.star-rating {
width:80px;
height: 1em;
background: #border_main;
.border_radius(3.631em);
clear:both;
span {
background: #color_links;
height:100%;
overflow: hidden;
float: left;
text-indent: -999em;
.borderbox;
.border_radius(3.631em);
span {
display: none;
}
}
}
p.stars {
overflow: hidden;
zoom: 1;
span {
width: 80px;
height: 16px;
position: relative;
float: left;
background: #border_main;
.border_radius(3.631em);
a {
float: left;
position: absolute;
left: 0;
top: 0;
width: 16px;
height: 0;
padding-top: 16px;
overflow: hidden;
}
a:hover, a:focus {
background: #color_links;
.border_radius(3.631em);
}
a.active {
background: #color_links;
.border_radius(3.631em);
}
a.star-1 { width: 16px; z-index: 10; .border_radius_left(3.631em); }
a.star-2 { width: 32px; z-index: 9; }
a.star-3 { width: 48px; z-index: 8; }
a.star-4 { width: 64px; z-index: 7; }
a.star-5 { width: 80px; z-index: 6; }
}
}
...along with some more for the widget areas, reviews, etc. etc.
I've found a few posts on how to override default WooCommerce star-ratings with a Theme's, but I can't find anything on doing the reverse. I did come across this:
http://findnerd.com/list/view/How-to-show-stars-instead-of-theme-ratings-in-Woocommerce/3854/
However it didn't work for me...
Any help would be much MUCH appreciated. Thank you!
EDIT:
I was informed this might be caused by my functions.php file. Here is the code found in wp-content->themes->Function-Child->functions.php
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
/*-----------------------------------------------------------------------------------*/
/* Start WooThemes Functions - Please refrain from editing this section */
/*-----------------------------------------------------------------------------------*/
// WooFramework init
require_once ( get_template_directory() . '/functions/admin-init.php' );
/*-----------------------------------------------------------------------------------*/
/* Load the theme-specific files, with support for overriding via a child theme.
/*-----------------------------------------------------------------------------------*/
$includes = array(
'includes/theme-options.php', // Options panel settings and custom settings
'includes/theme-functions.php', // Custom theme functions
'includes/theme-actions.php', // Theme actions & user defined hooks
'includes/theme-comments.php', // Custom comments/pingback loop
'includes/theme-js.php', // Load JavaScript via wp_enqueue_script
'includes/sidebar-init.php', // Initialize widgetized areas
'includes/theme-widgets.php', // Theme widgets
'includes/theme-plugin-integrations.php' // Plugin integrations
);
// Allow child themes/plugins to add widgets to be loaded.
$includes = apply_filters( 'woo_includes', $includes );
foreach ( $includes as $i ) {
locate_template( $i, true );
}
/*-----------------------------------------------------------------------------------*/
/* You can add custom functions below */
/*-----------------------------------------------------------------------------------*/
This is the exact same as the code in my regular (non-child) theme's functions.php file. I do have some custom code below this, however none of it relates to anything that would be relevant here.
EDIT 2:
OK I think I'm getting closer here!! I found this file wp-content/themes/function/includes/integrations/woocommerce/woocommerce.php which included this code at the top:
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
global $woo_options;
add_theme_support( 'woocommerce' );
// Disable WooCommerce styles
if ( version_compare( WOOCOMMERCE_VERSION, '2.1' ) >= 0 ) {
// WooCommerce 2.1 or above is active
add_filter( 'woocommerce_enqueue_styles', '__return_false' );
} else {
// WooCommerce less than 2.1 is active
define( 'WOOCOMMERCE_USE_CSS', false );
}
// Load WooCommerce stylsheet
if ( ! is_admin() ) { add_action( 'wp_enqueue_scripts', 'woo_load_woocommerce_css', 20 ); }
if ( ! function_exists( 'woo_load_woocommerce_css' ) ) {
function woo_load_woocommerce_css () {
wp_register_style( 'woocommerce', esc_url( get_template_directory_uri() . '/includes/integrations/woocommerce/css/woocommerce.css' ) );
wp_enqueue_style( 'woocommerce' );
} // End woo_load_woocommerce_css()
}
When I deleted the above code, the progress bars changed a little, and in the add new review section I could actually see two blue STARS laid on top of the blank progress bar (which normally highlights blue when you scroll over to choose your rating). So it seems that removing this kinda half fixed the problem. Any further suggestions?
I have problem with WooCommerce sidebar on archive-page and categories page,
Its display under my products ( right after page-pagi )
I tried to style it with css, like
.woocommerce .products ul, .woocommerce ul.products { width: 70%; float: right )
.sidebar { width: 29%; float: left;}
But it looks like it's in completely another section or something cause this have no effect.
If your theme isn't configured to work with woocommerce, and you've just installed it, it will probably be totally messed up. What you can do is add your own containers. Put these in functions.php
if (!function_exists('custom_open_woocommerce_content_wrappers')) {
function custom_open_woocommerce_content_wrappers(){
echo '<div class="container shop_container"><div class="row">';
}
}
if (!function_exists('custom_close_woocommerce_content_wrappers')) {
function custom_close_woocommerce_content_wrappers(){
echo '</div></div>';
}
}
if (!function_exists('custom_product_wrapper_open')) {
function custom_product_wrapper_open(){
echo '<div class="span8 content_with_right_sidebar">';
}
}
if (!function_exists('custom_product_wrapper_close')) {
function custom_product_wrapper_close(){
echo '</div>';
}
}
if (!function_exists('custom_before_shop_loop_sidebar')) {
function custom_before_shop_loop_sidebar() {
echo '<aside class="span4 sidebar sidebar_right">';
dynamic_sidebar('Sidebar Name Goes Here');
echo '</aside>';
}
}
add_action( 'woocommerce_after_shop_loop', 'custom_before_shop_loop_sidebar', 20);
if (!function_exists('custom_prepare_woocommerce_wrappers')) {
function custom_prepare_woocommerce_wrappers(){
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_output_content_wrapper', 10);
remove_action( 'woocommerce_after_shop_loop', 'woocommerce_output_content_wrapper_end', 10);
add_action( 'woocommerce_before_main_content', 'custom_open_woocommerce_content_wrappers', 10 );
add_action( 'woocommerce_after_main_content', 'custom_close_woocommerce_content_wrappers', 10 );
add_action( 'woocommerce_before_shop_loop', 'custom_product_wrapper_open', 10 );
add_action( 'woocommerce_after_shop_loop', 'custom_product_wrapper_close', 10 );
}
}
add_action( 'wp_head', 'custom_prepare_woocommerce_wrappers' );
This will create a wrapper with a right sidebar. And you can style it with
.container{
width: 1170px;
margin: 0 auto;
}
.row{
width: 100%;
}
.row:before,
.row:after{
display: table;
line-height: 0;
content: "";
}
.row:after{
clear: both;
}
.row > [class*="span"]{
display: block;
float: left;
width: 100%;
min-height: 20px;
margin-left: 2.564102564102564%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.row > [class*="span"]:first-child{
margin-left: 0;
}
.row .span8 {width: 65.81196581196581%;}
.row .span4 {width: 31.62393162393162%;}
Etc.
You can customize the wrappers to your liking, add options to choose left/right no sidebar by linking it with customizer, etc.
Basically, you can add your own classes in those divs, that will suit your needs. This one has these classes because when I'm working with themes I use grid that has 12 columns, and it has container with 1170px width and row and spans (1-12 corresponding to columns).
Hope this helps :)
set .woocommerce and .sidebar padding and margin = 0