// Function.php
add_action( 'woocommerce_product_options_pricing', 'add_international_to_products' );
function add_international_to_products() {
woocommerce_wp_text_input( array(
'id' => 'international_price',
'class' => 'short wc_input_price',
'label' => __( 'International Price', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . ')',
'data_type' => 'price',
));
}
add_action( 'save_post_product', 'save_international' );
function save_international( $product_id ) {
global $typenow;
if ( 'product' === $typenow ) {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
if ( isset( $_POST['international_price'] ) ) {
update_post_meta( $product_id, 'international_price', $_POST['international_price'] );
}
}
}
// Display Code hook throw
add_action( 'woocommerce_single_product_summary', 'display_international', 9 );
function display_international() {
global $product;
if ( $product->get_type() <> 'variable' && $rrp = get_post_meta( $product->get_id(), 'international_price', true ) ) {
echo '<div class="woocommerce_international_price">';
echo '<span>' . wc_price( $rrp ) . '</span>';
_e( '<p>for International Customer</p> ', 'woocommerce' );
echo '</div>';
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter