foreach( $order->get_items() as $item_id => $item ) :
//$item - это и будет ваш продукт
wp_kses_post($item->get_name());
endforeach;
add_action( 'woocommerce_after_shop_loop_item', 'ruta_custom_product_card_details', 6 );
function ruta_custom_product_card_details() {
global $post;
if ( has_term( [ 'exclusive' ], 'product_cat', $post->ID ) ) {
printf( '<div class="product-card__badges_exclusive">%s</div>', __( 'Exclusive', 'text-domain' ) );
}
}
//функция для изменения цен с помощью числа
function wpp_price_plus() {
return 100;
}
add_filter('woocommerce_product_variation_get_regular_price', 'wpp_custom_price', 99, 2 );
add_filter('woocommerce_product_variation_get_price', 'wpp_custom_price', 99, 2 );
function wpp_custom_price( $price, $product ) {
return (float) $price + wpp_price_plus();
}
add_filter('woocommerce_variation_prices_price', 'wpp_custom_variable_price', 99, 3 );
add_filter('woocommerce_variation_prices_regular_price', 'wpp_custom_variable_price', 99, 3 );
function wpp_custom_variable_price( $price, $variation, $product ) {
// Удаление кэшированной цены продукта
wc_delete_product_transients($variation->get_id());
return (float) $price + wpp_price_plus();
}
// Обработка кэширования цен
add_filter( 'woocommerce_get_variation_prices_hash', 'add_price_plus_to_variation_prices_hash', 99, 3 );
function add_price_plus_to_variation_prices_hash( $price_hash, $product, $for_display ) {
$price_hash[] = wpp_price_plus();
return $price_hash;
}
foreach(WC()->cart->get_cart() as $cart_item ){
$sale = get_post_meta( $cart_item['product_id'], '_sale_price', true );
if(! isset($sale) ) :
$product_price = get_post_meta( $cart_item['product_id'], 'woo_second_price', true );
$products_total += $product_price * $cart_item['quantity'];
endif:
}
add_action( 'woocommerce_cart_calculate_fees', 'wpp_custom_surcharge' );
function wpp_custom_surcharge() {
global $woocommerce;
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
return;
}
$percentage = 0.15;
$time = date( 'H' );
if ( 11 <= (int) $time && 12 > (int) $time ) :
$surcharge = ( $woocommerce->cart->cart_contents_total + $woocommerce->cart->shipping_total ) * $percentage;
$woocommerce->cart->add_fee( 'Счастливый час', - $surcharge, true, '' );
endif;
}