Hey,
When I try to add data to a cloneable group which already has a group the data overwrites the existing group. How do I add a new set of data whilst preserving the existing data?
Group code
'name' => __( 'Payments', 'your-text-domain' ),
'id' => $prefix . 'fr_payments',
'type' => 'group',
'clone' => true,
'hide_from_front' => true,
'fields' => [
[
'name' => __( 'Amount', 'your-text-domain' ),
'id' => $prefix . 'fr_payment_amount',
'type' => 'number',
'readonly' => true,
'prepend' => '£',
],
[
'name' => __( 'Stripe Payment Intent ID', 'your-text-domain' ),
'id' => $prefix . 'fr_stripe_payment_intent_id',
'type' => 'text',
'readonly' => true,
],
[
'name' => __( 'Date Paid', 'your-text-domain' ),
'id' => $prefix . 'fr_date_paid',
'type' => 'text',
'readonly' => true,
],
],
Update code:
$payment_meta[] =
[
'fr_payment_amount' => $this->stripe_pi_amt,
'fr_stripe_payment_intent_id' => $this->stripe_pi_id,
'fr_date_paid' => date('j F Y')
];
update_post_meta($this->order_id, 'fr_payments', $payment_meta);
Thanks