remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 15 );
[products limit="48" category="petli, ruchki, furnitura, zamki" cat_operator="NOT IN" orderby="rand" paginate="true"]
<?php
$current = absint( max( 1, get_query_var( 'paged' ) ? get_query_var( 'paged' ) : get_query_var( 'page' ) ) );
$args = array(
'post_type' => 'product',
'posts_per_page' => 8,
'paged' => $current,
'order' => 'rand',
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'slug', // Or 'name' or 'term_id'
'terms' => array('hoodies'),
'operator' => 'NOT IN', // Excluded
)
)
);
$query = new WP_Query($args);
?>
<?php if( $query->have_posts() ) : ?>
<?php while( $query->have_posts() ) : $query->the_post(); ?>
<div class="product">
<!-- тут вывод карточки продукта -->
</div>
<?php endwhile; ?>
<nav class="navigation pagination">
<div class="nav-links">
<?php
echo wp_kses_post(
paginate_links( [
'total' => $query->max_num_pages, // количество берем из дефолтной опции запроса
'current' => $current, // текущая страница
] )
);
?>
</div>
</nav>
<?php else: ?>
<div class="post">
<h2><?php _e( 'Posts not found', 'basic' ); ?></h2>
<?php get_search_form(); ?>
</div>
<?php endif; ?>
<?php wp_reset_query(); ?>
function your_theme_widgets_init() {
register_sidebar(
array(
'name' => esc_html__( 'Sidebar Shop', 'your_theme' ),
'id' => 'sidebar-shop',
'description' => esc_html__( 'Sidebar for shop', 'your_theme' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
)
);
}
add_action( 'widgets_init', 'your_theme_widgets_init' );
add_filter( 'woocommerce_shop_loop_subcategory_title', 'add_text_before_cat_title', 15 );
function add_text_before_cat_title( $category ) {
$slug = $category->slug;
if ( $slug === 'decor' ) {
echo 'from 10500 $';
} elseif ( $slug === 'music' ) {
echo 'from 5600 $';
} else {
return;
}
}
add_filter( 'woocommerce_get_price_html', 'cw_change_product_price_display' );
add_filter( 'woocommerce_cart_item_price', 'cw_change_product_price_display' );
function cw_change_product_price_display( $price ) {
// Your additional text in a translatable string
$text = __('от');
// returning the text before the price
return $text . ' ' . $price;
}
$term = get_queried_object();
$my_gallery = get_field('my_gallery', $term);
echo do_shortcode($my_gallery);
function archive_product_shortcode() {
$term = get_queried_object();
if ( function_exists('get_field') ) {
$my_shortcode = get_field('my_shortcode', $term);
echo do_shortcode( $my_shortcode );
}
}
add_action('woocommerce_archive_description', 'archive_product_shortcode', 20 );
$params = array(
'posts_per_page' => 12,
'post_type' => array('product', 'product_variation'),
'meta_query' => array(
array(
'key' => '_stock_status',
'value' => 'outofstock'
)
)
);
$wc_query = new WP_Query($params);
if ($wc_query->have_posts()) :
while ($wc_query->have_posts()) : $wc_query->the_post(); ?>
<?php wc_get_template_part( 'content', 'product' ); ?>
<?php endwhile;
wp_reset_postdata();
else: ?>
<p><?php _e( 'No Products' );?></p>
<?php endif; ?>
/**
* Change number of products that are displayed per page (shop page)
*/
add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 );
function new_loop_shop_per_page( $cols ) {
// $cols contains the current number of products per page based on the value stored on Options –> Reading
// Return the number of products you wanna show per page.
$cols = 9;
return $cols;
}
add_action('woocommerce_before_add_to_cart_form', 'basic_price', 15 );
function basic_price() {
$price = get_post_meta( get_the_ID(), '_regular_price', true);
$formatted_price = wc_price( $price );
if( has_term( ['laminat'], 'product_cat' ) ) {
echo '<span class="ri ri-clock">Стоимость упаковки: <span class="woocommerce-Price-amount amount">'. $formatted_price .'</span></span>'; // Print new html with title and price
}
}
<ul class="header-top-register">
<?php if(is_user_logged_in()):
$account_page = get_page_by_path('my-account', '', 'page');
?>
<li><a href="<?php the_permalink($account_page) ?>"><?php _e('Кабінет', 'viche') ?></a></li>
<li><a href="<?php echo wp_logout_url(get_permalink()); ?>"><?php _e('Вихід', 'viche') ?></a></li>
<?php else: ?>
<li><a href="javascript:void(0);" class="open-modal-btn" data-target="modal-sign-in"><?php _e('Авторизація', 'viche') ?></a></li>
<li><a href="javascript:void(0);" class="open-modal-btn" data-target="modal-register"><?php _e('Реєстрація', 'viche') ?></a></li>
<?php endif; ?>
</ul>