wc_get_account_saved_payment_methods_list دریافت لیست روش پرداختی کاربر

wc_get_account_saved_payment_methods_list دریافت لیست روش پرداختی کاربر

تابع ووکامرسی wc_get_account_saved_payment_methods_list – دریافت لیست های روش پرداختی که کاربر ذخیره کرده است .

Syntax – سینتکس

(array) wc_get_account_saved_payment_methods_list( (array) $list, (int) $customer_id ); 

Parameters – پارامتر ها (2)

  • 1- $list (array)
  • 2- $customer_id (int)

Returns – مقادیر بازگشتی (array)

Filtered list of customers payment methods

Usage – نحوه استفاده

if ( !function_exists( 'wc_get_account_saved_payment_methods_list' ) ) { 
    require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-account-functions.php'; 
} 
  
// List of payment methods passed from wc_get_customer_saved_methods_list() 
$list = array(); 
  
// The customer to fetch payment methods for 
$customer_id = -1; 
  
// NOTICE! Understand what this does before running. 
$result = wc_get_account_saved_payment_methods_list($list, $customer_id); 
    

Defined – محل تعریف

/includes/wc-account-functions.php

function wc_get_account_saved_payment_methods_list( $list, $customer_id ) { 
    $payment_tokens = WC_Payment_Tokens::get_customer_tokens( $customer_id ); 
    foreach ( $payment_tokens as $payment_token ) { 
        $delete_url = wc_get_endpoint_url( 'delete-payment-method', $payment_token->get_id() ); 
        $delete_url = wp_nonce_url( $delete_url, 'delete-payment-method-' . $payment_token->get_id() ); 
        $set_default_url = wc_get_endpoint_url( 'set-default-payment-method', $payment_token->get_id() ); 
        $set_default_url = wp_nonce_url( $set_default_url, 'set-default-payment-method-' . $payment_token->get_id() ); 
 
        $type = strtolower( $payment_token->get_type() ); 
        $list[ $type ][] = array( 
            'method' => array( 
                'gateway' => $payment_token->get_gateway_id(),  
 ),  
            'expires' => esc_html__( 'N/A', woocommerce ),  
            'is_default' => $payment_token->is_default(),  
            'actions' => array( 
                'delete' => array( 
                    'url' => $delete_url,  
                    'name' => esc_html__( 'Delete', woocommerce ),  
 ),  
 ),  
 ); 
        $key = key( array_slice( $list[ $type ], -1, 1, true ) ); 
 
        if ( ! $payment_token->is_default() ) { 
            $list[ $type ][ $key ]['actions']['default'] = array( 
                'url' => $set_default_url,  
                'name' => esc_html__( 'Make default', woocommerce ),  
 ); 
        } 
 
        $list[ $type ][ $key ] = apply_filters( 'woocommerce_payment_methods_list_item', $list[ $type ][ $key ], $payment_token ); 
    } 
    return $list; 
} 

versions – نسخه ها

از نسخه : 2.6

نسخه فعلی : 3.0.6

دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2

ارسال نظر

جهت استفاده از کد حتما از تگ pre استفاده نمایید .

contact us