<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
$post_type = get_post_type( $post_id );
if ($post_type=='product') {
global $product;
?>
<div class="quantity">
Количество: <button type="button" id="remove_one">-</button><input type="text" name="<?php echo esc_attr( $input_name ); ?>" value="<?php echo esc_attr( $input_value ); ?>" title="<?php echo esc_attr_x( 'Qty', 'Product quantity input tooltip', 'woocommerce' ) ?>" class="input-text qty text" size="4" pattern="<?php echo esc_attr( $pattern ); ?>" inputmode="<?php echo esc_attr( $inputmode ); ?>" /><button type="button" id="add_one">+</button>
<div class="order-summ">Сумма: <span id="orderSumm"><?php echo $product->get_price();?></span> грн.</div>
</div>
<script>
var price = jQuery('#orderSumm').html();
var quantity;
var summ;
jQuery('#remove_one').on('click',function(){
quantity = jQuery('input.qty').val();
if (quantity <= 1) {
summ = price*quantity;
jQuery('input.qty').val(quantity);
jQuery('#orderSumm').html(summ);
} else {
quantity--;
summ = price*quantity;
jQuery('input.qty').val(quantity);
jQuery('#orderSumm').html(summ);
}
});
jQuery('#add_one').on('click',function(){
quantity = jQuery('input.qty').val();
quantity++;
summ = price*quantity;
jQuery('input.qty').val(quantity);
jQuery('#orderSumm').html(summ);
});
jQuery('input.qty').keyup(function(){
var removedText = $(this).val().replace(/\D/, '');
jQuery(this).val(removedText);
quantity = jQuery(this).val();
summ = price*quantity;
jQuery('input.qty').val(quantity);
jQuery('#orderSumm').html(summ);
});
</script>
<?php } else {?>
<div class="quantity">
<input type="number" step="<?php echo esc_attr( $step ); ?>" min="<?php echo esc_attr( $min_value ); ?>" max="<?php echo esc_attr( $max_value ); ?>" name="<?php echo esc_attr( $input_name ); ?>" value="<?php echo esc_attr( $input_value ); ?>" title="<?php echo esc_attr_x( 'Qty', 'Product quantity input tooltip', 'woocommerce' ) ?>" class="input-text qty text" size="4" pattern="<?php echo esc_attr( $pattern ); ?>" inputmode="<?php echo esc_attr( $inputmode ); ?>" />
</div>
<?php }?>
get_the_terms( $product->id, 'pa_color');
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
if ( is_user_logged_in() ) {
unset( $tabs['additional_information'] );
}
return $tabs;
}
<?php $names = array ('один атрибут', 'второй атрибут') //имена атрибутов, которые не будем показывать
foreach ( $attributes as $attribute ) :
if ( !is_user_logged_in() && in_array($attribute['name'], $names ) {
continue; //пропускаем атрибут
}
if ( empty( $attribute['is_visible'] ) || ( $attribute['is_taxonomy'] && ! taxonomy_exists( $attribute['name'] ) ) ) {
continue;
} else {
$has_row = true;
}
?>
<tr class="<?php if ( ( $alt = $alt * -1 ) == 1 ) echo 'alt'; ?>">
<th><?php echo wc_attribute_label( $attribute['name'] ); ?></th>
//далее остальной файл
add_action( 'woocommerce_after_shop_loop_item_title', 'show_attributes', 20 );
function show_attributes() {
global $product;
if ($product->product_type == 'variable') {
$attributes = $product->get_attributes();?>
<ul>
<?php $variations_ids = $product->get_children();
foreach ($variations_ids as $variation_id) {
$variation = $product->get_child($variation_id);
$variation_data = $variation->get_variation_attributes();
$attributes = $variation->parent->get_attributes();
$description = array();
$attr_name = '';
if ( is_array( $variation_data ) ) {
foreach ( $attributes as $attribute ) {
if ( ! $attribute[ 'is_variation' ] ) {
continue;
}
$variation_selected_value = isset( $variation_data[ 'attribute_' . sanitize_title( $attribute[ 'name' ] ) ] ) ? $variation_data[ 'attribute_' . sanitize_title( $attribute[ 'name' ] ) ] : '';
$description_name = esc_html( wc_attribute_label( $attribute[ 'name' ] ) );
$description_value = __( 'Any', 'woocommerce' );
if ( $attribute[ 'is_taxonomy' ] ) {
$post_terms = wp_get_post_terms( $variation->id, $attribute[ 'name' ] );
foreach ( $post_terms as $term ) {
if ( $variation_selected_value === $term->slug ) {
$description_value = esc_html( apply_filters( 'woocommerce_variation_option_name', $term->name ) );
}
}
} else {
$options = wc_get_text_attributes( $attribute[ 'value' ] );
foreach ( $options as $option ) {
if ( sanitize_title( $variation_selected_value ) === $variation_selected_value ) {
if ( $variation_selected_value !== sanitize_title( $option ) ) {
continue;
}
} else {
if ( $variation_selected_value !== $option ) {
continue;
}
}
$description_value = esc_html( apply_filters( 'woocommerce_variation_option_name', $option ) );
}
}
$description[] = rawurldecode( $description_value );
}
$attr_name .= implode( '', $description );
} ?>
<li><?php echo $attr_name;?> - <?php echo $variation->get_price_html();?></li>
<?php } ?>
</ul>
<?php }
}
is_tax();
if ( is_tax( 'product_cat', 'primer' )) {
$args = array(
'theme_location' => 'sidebar-menu',
'menu_class' => 'sidebar-nav',
);
wp_nav_menu($args);
}
else{
$args = array(
'theme_location' => 'sidebar-menu-2',
'menu_class' => 'sidebar-nav',
);
wp_nav_menu($args);
}
woocommerce_content()
, которая определяет тип страницы и подтягивает нужный шаблон из шаблонов в самом плагине. Все шаблоны вы можете переопределять и кастомизировать. Оставляете главную на сайте как есть. index.php, например, или как у вас сейчас, я не знаю. Там вероятно есть header.php и footer.php. Создайте header-shop.php и footer-shop.php для использования на страницах магазина. Подключайте так get_header('shop');
Еще почитайте здесь virtum.com.ua/sozdanie-temy-dlya-woocommerce-kratk... add_filter( 'manage_edit-product_sortable_columns', 'my_product_sorting_column' );
function my_product_sorting_column( $columns ) {
$columns['is_in_stock'] = 'in_stock';
return $columns;
}
add_action( 'pre_get_posts', 'my_product_sorting' );
function my_product_sorting( $query ) {
if( ! is_admin() )
return;
$orderby = $query->get( 'orderby');
if( 'in_stock' == $orderby ) {
$query->set('meta_key','_stock_status');
$query->set('orderby','meta_value');
}
}
<ul>
<?php
$terms = get_terms( 'product_cat', array( 'child_of' => 30, ) );
foreach ($terms as $term) {
echo '<li><a href="'.get_term_link($term,'product_cat').'">'.$term->name.'</a></li>';
} ?>
</ul>