get_image(), $cart_item, $cart_item_key );
if ( ! $product_permalink ) {
echo $thumbnail;
}
else {
printf( '
', esc_url( $product_permalink ), $thumbnail ); // PHPCS: XSS ok.
}
?>
';
echo '
Толщина: ' . esc_html( $calc['thickness'] ) . ' мм
';
echo '
Ширина: ' . esc_html( $calc['width'] ) . ' мм
';
echo '
Длина: ' . esc_html( $calc['length'] ) . ' мм
';
// Итоговая цена за 1 лист после Длины
echo '
Итоговая цена за 1 лист: ' . wc_price($price) . '';
if ($regular_price > $price) {
echo ' ' . wc_price($regular_price) . '';
}
echo '
';
echo '
';
} elseif ( $_product->is_type('variation') ) {
$variation = wc_get_product( $cart_item['variation_id'] );
if ( $variation ) {
// Проверяем ширину и длину для определения листового материала
$width_meta = get_post_meta( $cart_item['variation_id'], '_variation_width', true );
if ( empty( $width_meta ) ) {
$width_meta = $variation->get_width();
}
$length_meta = get_post_meta( $cart_item['variation_id'], '_variation_length', true );
if ( empty( $length_meta ) ) {
$length_meta = $variation->get_length();
}
if ( $width_meta && $length_meta ) {
// Листовые материалы — отображение как у оргстекла
$attributes = $variation->get_variation_attributes();
$thickness_value = '';
foreach ( $attributes as $attr_key => $attr_value ) {
$attr_slug = str_replace( 'attribute_pa_', '', $attr_key );
$attr_slug = str_replace( 'attribute_', '', $attr_slug );
if ( stripos( $attr_slug, 'ves' ) !== false ) {
continue;
}
$taxonomy_name = str_replace( 'attribute_', '', $attr_key );
$term = get_term_by( 'slug', $attr_value, $taxonomy_name );
$thickness_value = $term ? $term->name : $attr_value;
break;
}
echo '
';
if ( $thickness_value ) {
$thickness_clean = preg_replace( '/\s*мм\s*$/u', '', $thickness_value );
$thickness_clean = preg_replace( '/\s*mm\s*$/i', '', $thickness_clean );
echo '
Толщина: ' . esc_html( trim( $thickness_clean ) ) . ' мм
';
}
echo '
Ширина: ' . esc_html( $width_meta ) . ' мм
';
echo '
Длина: ' . esc_html( $length_meta ) . ' мм
';
echo '
';
} else {
// Для остальных вариативных товаров (трубы/стержни/клей)
$attributes = $variation->get_variation_attributes();
$has_params = false;
$params_html = '';
foreach ( $attributes as $attr_key => $attr_value ) {
$attr_slug = str_replace( 'attribute_pa_', '', $attr_key );
$attr_slug = str_replace( 'attribute_', '', $attr_slug );
if ( $attr_slug === 'ves' || $attr_slug === 'pa_ves' || stripos( $attr_slug, 'ves' ) !== false ) {
continue;
}
$taxonomy_name = str_replace( 'attribute_', '', $attr_key );
$attr_name = '';
$attr_slug_clean = str_replace( 'pa_', '', $taxonomy_name );
$all_attr_taxonomies = wc_get_attribute_taxonomies();
foreach ( $all_attr_taxonomies as $tax ) {
if ( $tax->attribute_name === $attr_slug_clean ) {
$attr_name = $tax->attribute_label;
break;
}
}
if ( empty( $attr_name ) ) {
$best_label = '';
$best_dist = PHP_INT_MAX;
foreach ( $all_attr_taxonomies as $tax ) {
$dist = levenshtein( $attr_slug_clean, $tax->attribute_name );
if ( $dist < $best_dist && $dist <= 3 ) {
$best_dist = $dist;
$best_label = $tax->attribute_label;
}
}
if ( ! empty( $best_label ) ) {
$attr_name = $best_label;
}
}
if ( empty( $attr_name ) ) {
$attr_name = wc_attribute_label( $taxonomy_name );
}
$term = get_term_by( 'slug', $attr_value, $taxonomy_name );
$attr_value_display = $term ? $term->name : $attr_value;
$attr_value_display = str_replace( array( ' mm', 'mm' ), ' мм', $attr_value_display );
$params_html .= '
' . esc_html( $attr_name ) . ': ' . esc_html( $attr_value_display ) . '
';
$has_params = true;
}
$length_only = get_post_meta( $cart_item['variation_id'], '_variation_length', true );
if ( empty( $length_only ) ) {
$length_only = $variation->get_length();
}
if ( $length_only ) {
$params_html .= '
Длина: ' . esc_html( $length_only ) . ' мм
';
$has_params = true;
}
if ( $has_params ) {
echo '
' . $params_html . '
';
}
}
}
}
// Для простых товаров (клей) - НЕ показываем вес здесь, он уже есть в cart-product__chars
?>
0 ? $price / $weight : 0 );
?>
Итоговая цена за 1 :
$price): ?>
Количество
is_sold_individually() ) {
$min_quantity = 1;
$max_quantity = 1;
}
else {
$min_quantity = 0;
$max_quantity = $_product->get_max_purchase_quantity();
}
$product_quantity = woocommerce_quantity_input(
array(
'input_name' => "cart[{$cart_item_key}][qty]",
'input_value' => $cart_item['quantity'],
'max_value' => $max_quantity,
'min_value' => $min_quantity,
'product_name' => $product_name,
),
$_product,
false
);
echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key, $cart_item );
?>
Удалить