cart->cart_contents_count); ?>
cart->cart_contents_count);
ob_start();
?>
%s ',
esc_url( $product->add_to_cart_url() ),
esc_attr( $product->get_id() ),
esc_attr( $product->get_sku() ),
esc_attr( isset( $quantity ) ? $quantity : 1 ),
$product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',$product->supports( 'ajax_add_to_cart' ) ? 'ajax_add_to_cart' : '',
esc_html( $product->add_to_cart_text() )
),$product );
return $cart_url;
}
function almaira_shop_sort_woo_category_list($category_list){
$cate_list = '
'.$category_list.'
';
return $cate_list;
}
function almaira_shop_sort_category_products(){
if( taxonomy_exists( 'product_cat' ) ){
$term_id = get_theme_mod('almaira_shop_sortby_cate',0);
// category filter
$args = array(
'orderby' => 'title',
'order' => 'ASC',
'hide_empty' => 1,
'include' => $term_id
);
$product_categories = get_terms( 'product_cat', $args );
$count = count($product_categories);
$category_list = $cate_product = '';
if ( $count > 0 ){
foreach ( $product_categories as $product_category ){
//global $product;
$category_product = array();
$current_class = '';
$category_list .='
' . $product_category->name . '
';
}
$cate_list = almaira_shop_sort_woo_category_list($category_list);
echo $cate_list;
}
}
}
/**********************************/
//almaira_shop_sort_filter_product_show (sortby section)
/**********************************/
function almaira_shop_sort_filter_product_show(){
$posts_per_page = get_theme_mod('almaira_shop_prd_shw','10');
$args = array(
'post_type' => 'product',
'posts_per_page' => $posts_per_page,
);
$product = new WP_Query( $args );
if ( $product->have_posts() ){
while ( $product->have_posts() ) : $product->the_post();
wc_get_template_part( 'content', 'product' );
endwhile;
} else {
echo __( 'No products found','almaira-shop' );
}
wp_reset_postdata();
}
/***************************/
// Product load more button
/***************************/
function almaira_shop_product_loadmore(){
$posts_per_page = get_theme_mod('almaira_shop_prd_shw','10');
if ( empty( $paged ) ){
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
}
$args = array(
'post_type' => 'product',
'posts_per_page' => $posts_per_page,
);
$product = new WP_Query( $args );
if ( $product->have_posts() ){
if($posts_per_page < $product->found_posts){
echo'
'.esc_html__( 'Load More', 'almaira-shop' ).'
';
}
}
wp_reset_postdata();
}
/**********************************/
//Shop Product Markup
/**********************************/
if ( ! function_exists( 'almaira_shop_product_meta_start' ) ){
/**
* Thumbnail wrap start.
*/
function almaira_shop_product_meta_start(){
echo '';
}
}
if ( ! function_exists( 'almaira_shop_product_meta_end' ) ){
/**
* Thumbnail wrap start.
*/
function almaira_shop_product_meta_end(){
echo '
';
}
}
/**********************************/
//Shop Product Image Markup
/**********************************/
if ( ! function_exists( 'almaira_shop_product_image_start' ) ){
/**
* Thumbnail wrap start.
*/
function almaira_shop_product_image_start(){
echo '';
}
}
if ( ! function_exists( 'almaira_shop_product_image_end' ) ){
/**
* Thumbnail wrap start.
*/
function almaira_shop_product_image_end(){
echo '
';
}
}
if ( ! function_exists( 'almaira_shop_product_content_start' ) ){
/**
* Thumbnail wrap start.
*/
function almaira_shop_product_content_start(){
echo '';
}
}
if ( ! function_exists( 'almaira_shop_product_content_end' ) ){
/**
* Thumbnail wrap start.
*/
function almaira_shop_product_content_end(){
echo '
';
}
}
/**
* Shop customization.
*
* @return void
*/
add_action( 'woocommerce_before_shop_loop_item', 'almaira_shop_product_meta_start', 10);
add_action( 'woocommerce_after_shop_loop_item', 'almaira_shop_product_meta_end', 12 );
add_action( 'woocommerce_before_shop_loop_item_title', 'almaira_shop_product_content_start',20);
add_action( 'woocommerce_after_shop_loop_item_title', 'almaira_shop_product_content_end', 20 );
/**********************************************
//product section function starts from here
**********************************************/
/* Funtion to show category list in product section */
function almaira_shop_product_sec_category_products(){
if( taxonomy_exists( 'product_cat' ) ){
$term_id = get_theme_mod('almaira_shop_product_cate',0);
$perpage = get_theme_mod('almaira_shop_cate_prd_shw',8);
// category filter
$args = array(
'orderby' => 'title',
'order' => 'ASC',
'hide_empty' => 1,
'include' => $term_id
);
$product_categories = get_terms( 'product_cat', $args );
$count = count($product_categories);
$cat_list = $cate_product = '';
$i=1;
if ( $count > 0 ){
foreach ( $product_categories as $product_category ){
//global $product;
$category_product = array();
$current_class = '';
$cat_list .='
'.esc_html($product_category->name).' ';
$i++;
}
$return = '';
return $return;
}
}
}
/****************/
// add to compare
/****************/
function almaira_shop_add_to_compare_fltr($pid=''){
if( is_plugin_active('yith-woocommerce-compare/init.php') ){
return '';
}
}
/**********************************************
//product section function End
**********************************************/
add_action( 'woocommerce_before_shop_loop_item_title', 'almaira_shop_product_image_start', 0);
add_action( 'woocommerce_before_shop_loop_item_title', 'almaira_shop_product_image_end',10 );
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_show_product_sale_flash',1);
/**********************/
/** wishlist **/
/**********************/
function almaira_shop_whish_list(){
if( shortcode_exists( 'yith_wcwl_add_to_wishlist' ) ){
return do_shortcode('[yith_wcwl_add_to_wishlist icon="fa fa-heart" browse_wishlist_text=""]' );
}
}
function almaira_shop_whishlist_url(){
$wishlist_page_id = get_option( 'yith_wcwl_wishlist_page_id' );
$wishlist_permalink = get_the_permalink( $wishlist_page_id );
return $wishlist_permalink ;
}
// shop almaira
/** My Account Menu **/
function almaira_shop_account(){
if ( is_user_logged_in() ) {
$return = ' ';
}
else {
$return = ' ';
}
echo $return;
}
// Plus Minus Quantity Buttons @ WooCommerce Single Product Page
add_action( 'woocommerce_before_add_to_cart_quantity', 'almaira_shop_display_quantity_plus',10,2 );
function almaira_shop_display_quantity_plus(){
echo '+ ';
}
add_action( 'woocommerce_after_add_to_cart_quantity', 'almaira_shop_display_quantity_minus',10,2 );
function almaira_shop_display_quantity_minus(){
echo '-
';
}
//Woocommerce: How to remove page-title at the home/shop page but not category pages
add_filter( 'woocommerce_show_page_title', 'not_a_shop_page' );
function not_a_shop_page() {
return boolval(!is_shop());
}