Açıklama Yok

payment-methods.php 3.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. * @package WooCommerce\Templates
  17. * @version 2.6.0
  18. */
  19. defined( 'ABSPATH' ) || exit;
  20. $saved_methods = wc_get_customer_saved_methods_list( get_current_user_id() );
  21. $has_methods = (bool) $saved_methods;
  22. $types = wc_get_account_payment_methods_types();
  23. do_action( 'woocommerce_before_account_payment_methods', $has_methods ); ?>
  24. <?php if ( $has_methods ) : ?>
  25. <table class="woocommerce-MyAccount-paymentMethods shop_table shop_table_responsive account-payment-methods-table">
  26. <thead>
  27. <tr>
  28. <?php foreach ( wc_get_account_payment_methods_columns() as $column_id => $column_name ) : ?>
  29. <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>
  30. <?php endforeach; ?>
  31. </tr>
  32. </thead>
  33. <?php foreach ( $saved_methods as $type => $methods ) : // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited ?>
  34. <?php foreach ( $methods as $method ) : ?>
  35. <tr class="payment-method<?php echo ! empty( $method['is_default'] ) ? ' default-payment-method' : ''; ?>">
  36. <?php foreach ( wc_get_account_payment_methods_columns() as $column_id => $column_name ) : ?>
  37. <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 ); ?>">
  38. <?php
  39. if ( has_action( 'woocommerce_account_payment_methods_column_' . $column_id ) ) {
  40. do_action( 'woocommerce_account_payment_methods_column_' . $column_id, $method );
  41. } elseif ( 'method' === $column_id ) {
  42. if ( ! empty( $method['method']['last4'] ) ) {
  43. /* translators: 1: credit card type 2: last 4 digits */
  44. echo sprintf( esc_html__( '%1$s ending in %2$s', 'woocommerce' ), esc_html( wc_get_credit_card_type_label( $method['method']['brand'] ) ), esc_html( $method['method']['last4'] ) );
  45. } else {
  46. echo esc_html( wc_get_credit_card_type_label( $method['method']['brand'] ) );
  47. }
  48. } elseif ( 'expires' === $column_id ) {
  49. echo esc_html( $method['expires'] );
  50. } elseif ( 'actions' === $column_id ) {
  51. foreach ( $method['actions'] as $key => $action ) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
  52. echo '<a href="' . esc_url( $action['url'] ) . '" class="button ' . sanitize_html_class( $key ) . '">' . esc_html( $action['name'] ) . '</a>&nbsp;';
  53. }
  54. }
  55. ?>
  56. </td>
  57. <?php endforeach; ?>
  58. </tr>
  59. <?php endforeach; ?>
  60. <?php endforeach; ?>
  61. </table>
  62. <?php else : ?>
  63. <p class="woocommerce-Message woocommerce-Message--info woocommerce-info"><?php esc_html_e( 'No saved methods found.', 'woocommerce' ); ?></p>
  64. <?php endif; ?>
  65. <?php do_action( 'woocommerce_after_account_payment_methods', $has_methods ); ?>
  66. <?php if ( WC()->payment_gateways->get_available_payment_gateways() ) : ?>
  67. <a class="button" href="<?php echo esc_url( wc_get_endpoint_url( 'add-payment-method' ) ); ?>"><?php esc_html_e( 'Add payment method', 'woocommerce' ); ?></a>
  68. <?php endif; ?>