Quote from Carmelo on February 25, 2021, 22:28
In fact it will possibile to buy only one product at time. I found this:
if(is_single( '7051' ) ) {
global $WOOCS;
$WOOCS->set_currency('EUR');
}
});
and for checkout this:
add_action('woocommerce_after_order_notes', 'conditional_checkout_field');
function conditional_checkout_field( $checkout ) {
// Set here your product IDS (in the array)
$product_ids = array( 6948, 7049, 7052 );
$is_in_cart = false;
// Iterating through cart items and check
foreach( WC()->cart->get_cart() as $cart_item_key => $cart_item )
if( in_array( $cart_item['data']->get_id(), $product_ids ) ){
$is_in_cart = true; // We set it to "true"
break; // At east one product, we stop the loop
}
// If condition match we display the field
if( $is_in_cart ){
global $WOOCS;
$WOOCS->set_currency('USD');
}
};
It miss a function for cart page... Can you recommend something?
In fact it will possibile to buy only one product at time. I found this:
if(is_single( '7051' ) ) {
global $WOOCS;
$WOOCS->set_currency('EUR');
}
});
and for checkout this:
add_action('woocommerce_after_order_notes', 'conditional_checkout_field');
function conditional_checkout_field( $checkout ) {
// Set here your product IDS (in the array)
$product_ids = array( 6948, 7049, 7052 );
$is_in_cart = false;
// Iterating through cart items and check
foreach( WC()->cart->get_cart() as $cart_item_key => $cart_item )
if( in_array( $cart_item['data']->get_id(), $product_ids ) ){
$is_in_cart = true; // We set it to"true"
break; // At east one product, we stop the loop
}
// If condition match we display the field
if( $is_in_cart ){
global $WOOCS;
$WOOCS->set_currency('USD');
}
};
It miss a function for cart page... Can you recommend something?