/templates/myaccount/payment-methods.php

  1. <?php 
  2. /** 
  3. * Payment methods 
  4. * 
  5. * Shows customer payment methods on the account page. 
  6. * 
  7. * This template can be overridden by copying it to yourtheme/woocommerce/myaccount/payment-methods.php. 
  8. * 
  9. * HOWEVER, on occasion WooCommerce will need to update template files and you 
  10. * (the theme developer) will need to copy the new files to your theme to 
  11. * maintain compatibility. We try to do this as little as possible, but it does 
  12. * happen. When this occurs the version of the template file will be bumped and 
  13. * the readme will list any important changes. 
  14. * 
  15. * @see https://docs.woocommerce.com/document/template-structure/ 
  16. * @author WooThemes 
  17. * @package WooCommerce/Templates 
  18. * @version 2.6.0 
  19. */ 
  20.  
  21. if ( ! defined( 'ABSPATH' ) ) { 
  22. exit; 
  23.  
  24. $saved_methods = wc_get_customer_saved_methods_list( get_current_user_id() ); 
  25. $has_methods = (bool) $saved_methods; 
  26. $types = wc_get_account_payment_methods_types(); 
  27.  
  28. do_action( 'woocommerce_before_account_payment_methods', $has_methods ); ?> 
  29.  
  30. <?php if ( $has_methods ) : ?> 
  31.  
  32. <table class="woocommerce-MyAccount-paymentMethods shop_table shop_table_responsive account-payment-methods-table"> 
  33. <thead> 
  34. <tr> 
  35. <?php foreach ( wc_get_account_payment_methods_columns() as $column_id => $column_name ) : ?> 
  36. <th class="woocommerce-PaymentMethod woocommerce-PaymentMethod--<?php echo esc_attr( $column_id ); ?> payment-method-<?php echo esc_attr( $column_id ); ?>"><span class="nobr"><?php echo esc_html( $column_name ); ?></span></th> 
  37. <?php endforeach; ?> 
  38. </tr> 
  39. </thead> 
  40. <?php foreach ( $saved_methods as $type => $methods ) : ?> 
  41. <?php foreach ( $methods as $method ) : ?> 
  42. <tr class="payment-method<?php echo ! empty( $method['is_default'] ) ? ' default-payment-method' : '' ?>"> 
  43. <?php foreach ( wc_get_account_payment_methods_columns() as $column_id => $column_name ) : ?> 
  44. <td class="woocommerce-PaymentMethod woocommerce-PaymentMethod--<?php echo esc_attr( $column_id ); ?> payment-method-<?php echo esc_attr( $column_id ); ?>" data-title="<?php echo esc_attr( $column_name ); ?>"> 
  45. <?php 
  46. if ( has_action( 'woocommerce_account_payment_methods_column_' . $column_id ) ) { 
  47. do_action( 'woocommerce_account_payment_methods_column_' . $column_id, $method ); 
  48. } elseif ( 'method' === $column_id ) { 
  49. if ( ! empty( $method['method']['last4'] ) ) { 
  50. /** translators: 1: credit card type 2: last 4 digits */ 
  51. echo sprintf( __( '%1$s ending in %2$s', 'woocommerce' ), esc_html( wc_get_credit_card_type_label( $method['method']['brand'] ) ), esc_html( $method['method']['last4'] ) ); 
  52. } else { 
  53. echo esc_html( wc_get_credit_card_type_label( $method['method']['brand'] ) ); 
  54. } elseif ( 'expires' === $column_id ) { 
  55. echo esc_html( $method['expires'] ); 
  56. } elseif ( 'actions' === $column_id ) { 
  57. foreach ( $method['actions'] as $key => $action ) { 
  58. echo '<a href="' . esc_url( $action['url'] ) . '" class="button ' . sanitize_html_class( $key ) . '">' . esc_html( $action['name'] ) . '</a> '; 
  59. ?> 
  60. </td> 
  61. <?php endforeach; ?> 
  62. </tr> 
  63. <?php endforeach; ?> 
  64. <?php endforeach; ?> 
  65. </table> 
  66.  
  67. <?php else : ?> 
  68.  
  69. <p class="woocommerce-Message woocommerce-Message--info woocommerce-info"><?php esc_html_e( 'No saved methods found.', 'woocommerce' ); ?></p> 
  70.  
  71. <?php endif; ?> 
  72.  
  73. <?php do_action( 'woocommerce_after_account_payment_methods', $has_methods ); ?> 
  74.  
  75. <a class="button" href="<?php echo esc_url( wc_get_endpoint_url( 'add-payment-method' ) ); ?>"><?php esc_html_e( 'Add payment method', 'woocommerce' ); ?></a> 
.