Unable to change price via PHP
-
I’ve tried editing a piece of code posted on your github account, but I get an error message Invalid integer: false.
The original code is here https://github.com/awesomemotive/wp-simple-pay-snippet-library/blob/master/plugins/custom-amount.php which works fine. It’s when I amend this code to get the value from ACF fields that the issue occurs, the edited code is below;add_filter( 'simpay_get_payment_form_price_options', function( $price_options, $form ) { global $post; $amount = 0.00; if (have_rows('items', $post->ID)) { while (have_rows('items', $post->ID)) { the_row(); $qty+=get_sub_field('quantity'); $amount+=get_sub_field('price')*get_sub_field('quantity'); } } $amount = $amount * 100; $form_id = 1111; $unit_amount = intval($amount); $currency = 'gbp'; $custom_amount = new \SimplePay\Core\PaymentForm\PriceOption( array( 'id' => 'simpay_custom_amount', 'currency' => $currency, 'unit_amount' => $unit_amount, 'unit_amount_min' => $unit_amount, 'default' => true, ), $form ); return array( $custom_amount ); }, 10, 2 );
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Unable to change price via PHP’ is closed to new replies.