Replies: 0
Hi everyone, Happy New Year. (I need your help)
I’m starting to create a Custom Payment, where I have a textbox that will allow me to enter any value and in turn will allow me to dynamically create a custom field with its value.
I am using a plugin called (WooCommerce Checkout Manager) of which I have for a product the process in 50% | 50%.
The Custom Payment created is for the user to enter the transfer code or deposit.
This is where the problem comes from.
When I start registering the first 50%, my custom field is successfully created, called deposit1.
My goal is that when the user processes the other 50% in a status of partially paid order I register my other custom field called deposit2
BUT …, I’M NOT REGISTERING A SECOND CUSTOM FIELD (deposit2)
I show them an example of the code (IT IS ONLY AN EXAMPLE I’VE BEEN TESTING TO SEE WHY I’M NOT REGISTERING A SECOND CUSTOM FIELD)
add_action( ‘woocommerce_checkout_update_order_meta’, ‘custom_payment_update_order_meta’ );
function custom_payment_update_order_meta( $order_id ) {
$woocommerce_text_field = $_POST[‘my_key’];
$custom_fields = get_post_custom($order_id);
$row_count = count($custom_fields);
switch ($row_count) {
case 0:
add_post_meta( $order_id, ‘my_key’, esc_attr( $woocommerce_text_field) );
break;
case 1:
add_post_meta( $order_id, ‘my_key’, esc_attr( $woocommerce_text_field) );
break;
case 2:
add_post_meta( $order_id, ‘my_key’, esc_attr( $woocommerce_text_field) );
break;
}
.
.
.
.
}
I hope your answers…