michael432
Forum Replies Created
-
I am sorry it took me long to reply. the given worked and task is resolved.
thank you very much for help and support 🙂hi,
thank you for quick replay and the code.
but I am bit confuse with this. You mentioned I should “save the customer’s payment method during the checkout process” using the given filter. Are you suggesting I should use ‘woocommerce_checkout_update_order_meta’ hook and save customer’s payment method and method ID in metadata? if so then I did a little search and came up with this: is it correct?add_action('woocommerce_checkout_update_order_meta', 'save_payment_method_data', 10, 2);
function save_payment_method_data($order_id, $data) {
$payment_method = WC()->session->get('chosen_payment_method');
$payment_method_id = get_user_meta(get_current_user_id(), '_payment_method_token', true);
if ($payment_method) {
update_post_meta($order_id, '_payment_method_used', sanitize_text_field($payment_method));
}
if ($payment_method_id) {
update_post_meta($order_id, '_payment_method_id', sanitize_text_field($payment_method_id));
}
}but how can I use this info inside my function which is:
add_action('template_redirect', 'process_upsell_with_payment');
function process_upsell_with_payment() { ... Payment method to get... }right now this is the code which was suppose to add payment method inside new order, the line right after ‘$new_order->calculate_totals();
$result = wc_get_payment_gateway_by_order($order)->process_payment_with_token($new_order, $payment_token);should I replace this code? but with what method I should replace it with? that the issue I am facing that I cannot find the right method and default method is not working .
what could be the function that is used by ‘Stripe payment plugin’ for adding payment method in order?If I know where the code is in file I can try that.
can you guide me to what file I should check?
If this is not possible then can show some sample code or document or article that I can check?
I am sorry if this is asking to much, its just is this last step I stuck on in this task and I will highly apricate any help. thank you in advance- This reply was modified 1 year, 4 months ago by michael432.
- This reply was modified 1 year, 4 months ago by Yui.