I'm trying to get a php file of a plugin that has been discontinued for three years to work, and not being a programmer I'm not succeeding .. In practice, once the price has been extracted from the woocommerce cart, I want it to be used to update the price on a QR code generator. The first part works, the second part works as well, but I can't get the "amount" parameter to read the $ total value. Thanks to who will help me.
// WooCommerce
add_action( 'woocommerce_order_details_after_order_table', array( $this, 'order_details_after_order_table' ) );
}
/**
* @todo refactor
*
* @param WC_Order $order
*/
public function order_details_after_order_table( $order ) {
$payment_method = $order->get_payment_method();
$total = $order->get_total();
if ( $payment_method === 'bacs' ) {
// temporary
echo $this->shortcode_qrcode();
echo $total; // correct return value (626)
}
}
public function shortcode_qrcode( $atts = [] ) {
$options = $this->options;
// custom param
$custom = shortcode_atts( array(
'id' => $options[ $this->field_key->field_promptpay_id ],
'amount' => 0 // I want use the $total in this point
), $atts );
$html = sprintf( '<div class="ppy-card"
data-promptpay-id="%s"
data-amount="%f"
data-show-promptpay-logo="%s"
data-show-promptpay-id="%s"
data-account-name="%s"
data-shop-name="%s"
data-card-style="%s"
></div>',
$custom['id'],
$custom['amount'],
$options[ $this->field_key->field_show_promptpay_logo ],
$options[ $this->field_key->field_show_promptpay_id ],
$options[ $this->field_key->field_account_name ],
$options[ $this->field_key->field_shop_name ],
1
);
return $html;
}