WordPress
- 17 ответов
- 0 вопросов
11
Вклад в тег
add_action( 'woocommerce_product_options_pricing', 'custom_woocommerce_product_options_pricing' );
function custom_woocommerce_product_options_pricing() {
$price_index = '_custom_price';
woocommerce_wp_text_input(
array(
'id' => $price_index,
'value' => get_post_meta( get_the_ID(), $price_index, true ),
'data_type' => 'price',
'label' => __( 'Custom price', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . ')'
)
);
}
add_action( 'woocommerce_admin_process_product_object', 'custom_woocommerce_admin_process_product_object', 10, 1 );
function custom_woocommerce_admin_process_product_object( $product ) {
$price_index = '_custom_price';
$price = wc_clean( wp_unslash( $_POST[ $price_index ] ) );
update_post_meta( $product->get_id(), $price_index, $price );
}
$price_index = '_custom_price';
echo wc_price( get_post_meta( get_the_ID(), $price_index, true ) );
https://realia.ua/prodazha-kvartir/room-2/type_object-ctudiya-2_h_i_bolee_urovnej/area-ot-25/cost-ot-500000/