woocommerce different locations code example

Example 1: how to add woocommerce cart counter

<a href="<?php echo wc_get_cart_url() ?>" class="misha-cart">Cart (<?php echo $woocommerce->cart->cart_contents_count ?>)</a>

Example 2: WooCommerce attributes

defauls:

show selected products by ID
[products limit="16" columns="4" ids="766,620,1033,624,626,960, 629,635,861"]

show products ob SALE
[products limit="" columns="4" orderby="popularity" class="quick-sale" on_sale="true"]

show selected category
[products limit="8" columns="4" category="hoodies, tshirts"]

show products by tags
[products tag="hoodie"]

special:
[lf_woo_products_carousel id="an_uniq_id" categories="selected category" loop="1" selected_products_tab="0"] => show category in carucell
"id" => the uniq id of a product or a shortcode with carusell
"col" => number of col's
"tablet_col" => number of col's in tablete
"mobile_col" => number of col's in mobile
"class" => Ex. "hight-400"
"direction" => of the carusella "horizontal" | "vertical"
"loop" => if it will loop or not "0"
"delay" => the time for shifting in milisec "3000"
"speed" => thr rotation spees "300"
"centered" => of the product "0"
"mousewheel" => will the mouse scroll thr carusel or not "0"
"nevigation" => show the arrow on the sides "1"
"pagination" => show the numbers of the pics "1"
"scrollbar" => show the scroll bars "0"
"photoswipe" => swipting the photos "0"
"categories" => the selected category to show spreted by comma (,) "null"
"tags" => the selected tags to show spreted by comma (,) "null"
"selected_products_tab" => whitch tab to show "0"
"new_products_tab" => show the new products "1"

Example 3: woocommerce availability

add_filter( 'woocommerce_get_availability', 'wcs_custom_get_availability', 1, 2);
function wcs_custom_get_availability( $availability, $_product ) {
    
    // Change In Stock Text
    if ( $_product->is_in_stock() ) {
        $availability['availability'] = __('Available!', 'woocommerce');
    }
    // Change Out of Stock Text
    if ( ! $_product->is_in_stock() ) {
        $availability['availability'] = __('Sold Out', 'woocommerce');
    }
    return $availability;
}

Example 4: Custom Widget Area woocommerce

<?php if ( is_active_sidebar( 'Primary Sidebar' ) ) : ?>
 
    <?php dynamic_sidebar( 'Primary Sidebar' ); ?>
 
<?php endif; ?>

Tags:

Php Example