I would like to create a modal box after click the add to cart button. But just if a checkbox is selected and inside an input there is a msg.
So I think the best way would be inside the function where the plugin, after the add to cart button is clicked, send the data to woocommerce.
Here it is the function
/**
* When added to cart, save any gift wrap data
*
* @access public
* @param mixed $cart_item_meta
* @param mixed $product_id
* @return void
*/
public function add_cart_item_data ($cart_item_meta, $product_id ) {
global $woocommerce;
$is_wrappable = get_post_meta( $product_id, '_is_gift_wrappable', true );
if ( $is_wrappable == '' && $this->gift_wrap_enabled )
$is_wrappable = 'yes';
if ( !empty( $_POST['gift_wrap'] ) && $is_wrappable == 'yes' )
$cart_item_meta['gift_wrap'] = true;
if ( !empty( $_POST['gift_wrap_selection'] ) && $is_wrappable == 'yes' )
$cart_item_meta['gift_wrap_selection'] = strip_tags( $_POST['gift_wrap_selection'] );
if ( !empty( $_POST['gift_wrap_inner_message'] ) && $is_wrappable == 'yes' ){
$cart_item_meta['gift_wrap_inner_message'] = strip_tags( $_POST['gift_wrap_inner_message'] );
}
if ( !empty( $_POST['gift_wrap_outer_message'] ) && $is_wrappable == 'yes' )
$cart_item_meta['gift_wrap_outer_message'] = strip_tags( $_POST['gift_wrap_outer_message'] );
return $cart_item_meta;
}
I think the best way is to call a function here:
if ( !empty( $_POST['gift_wrap_inner_message'] ) && $is_wrappable == 'yes' ){
$cart_item_meta['gift_wrap_inner_message'] = strip_tags( $_POST['gift_wrap_inner_message'] );
}