Skip to content

Commit

Permalink
show the correct payment method used
Browse files Browse the repository at this point in the history
  • Loading branch information
Timo committed Sep 15, 2020
1 parent f1efeb1 commit 450af46
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 32 deletions.
33 changes: 33 additions & 0 deletions includes/abstracts/class-wc-gateway-mondido-abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,39 @@ public function cancelMondidoSubscription( $subscription_id ) {
return json_decode( $result['body'], TRUE );
}

public function get_payment_method_name($value, $order, $default_value)
{
$transaction = get_post_meta( $order->get_id(), '_mondido_transaction_data', TRUE );

if (!empty($transaction['transaction_type'])) {
switch ($transaction['transaction_type']) {
case 'after_pay': return __('After Pay', 'woocommerce-gateway-mondido');
case 'amex': return __('American Express', 'woocommerce-gateway-mondido');
case 'bank': return __('Bank', 'woocommerce-gateway-mondido');
case 'credit_card': return __('Card', 'woocommerce-gateway-mondido');
case 'diners': return __('Diners', 'woocommerce-gateway-mondido');
case 'discover': return __('Discover', 'woocommerce-gateway-mondido');
case 'e_payment': return __('E-payment', 'woocommerce-gateway-mondido');
case 'e_payments': return __('E-Payments', 'woocommerce-gateway-mondido');
case 'invoice': return __('Invoice', 'woocommerce-gateway-mondido');
case 'jcb': return __('JCB', 'woocommerce-gateway-mondido');
case 'manual_invoice': return __('Manual Invoice', 'woocommerce-gateway-mondido');
case 'mastercard': return __('Mastercard', 'woocommerce-gateway-mondido');
case 'mobile_pay': return __('Mobile Pay', 'woocommerce-gateway-mondido');
case 'payment': return __('Payment', 'woocommerce-gateway-mondido');
case 'paypal': return __('PayPal', 'woocommerce-gateway-mondido');
case 'recurring': return __('Recurring', 'woocommerce-gateway-mondido');
case 'siirto': return __('Siirto', 'woocommerce-gateway-mondido');
case 'stored_card': return __('Stored card', 'woocommerce-gateway-mondido');
case 'swish': return __('Swish', 'woocommerce-gateway-mondido');
case 'vipps': return __('Vipps', 'woocommerce-gateway-mondido');
case 'visa': return __('Visa', 'woocommerce-gateway-mondido');
}
}

return $default_value;
}

private function get_country_alpha2($code)
{
$map = new League\ISO3166\ISO3166();
Expand Down
11 changes: 11 additions & 0 deletions includes/class-wc-gateway-mondido-hw.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ public function __construct() {
$this,
'add_form_hash_value'
), 10, 3 );

add_filter('woocommerce_order_get_payment_method_title', array($this, 'woocommerce_order_get_payment_method_title'), 0, 2);
}

/**
Expand Down Expand Up @@ -718,4 +720,13 @@ public function get_active_payment_logos() {

return $active_logos;
}

public function woocommerce_order_get_payment_method_title($value, $order)
{
if ($order->get_payment_method() !== $this->id) {
return $value;
}

return $this->get_payment_method_name($value, $order, $this->method_title);
}
}
11 changes: 11 additions & 0 deletions includes/class-wc-gateway-mondido-preselect.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public function __construct($preselected_method, $method_title, $button_text, $d
'set_payment_method'
), 10, 3 );

add_filter('woocommerce_order_get_payment_method_title', array($this, 'woocommerce_order_get_payment_method_title'), 0, 2);

// Actions
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array(
$this,
Expand Down Expand Up @@ -184,4 +186,13 @@ public function set_payment_method( $fields, $order, $gateway ) {

return $fields;
}

public function woocommerce_order_get_payment_method_title($value, $order)
{
if ($order->get_payment_method() !== $this->id) {
return $value;
}

return $this->get_payment_method_name($value, $order, $this->method_title);
}
}
Binary file modified languages/woocommerce-gateway-mondido-sv_SE.mo
Binary file not shown.
101 changes: 69 additions & 32 deletions languages/woocommerce-gateway-mondido-sv_SE.po
Original file line number Diff line number Diff line change
Expand Up @@ -144,38 +144,10 @@ msgstr ""
msgid "Logos on checkout"
msgstr ""

#: ../includes/class-wc-gateway-mondido-hw.php:173
msgid "Visa"
msgstr ""

#: ../includes/class-wc-gateway-mondido-hw.php:174
msgid "MasterCard"
msgstr ""

#: ../includes/class-wc-gateway-mondido-hw.php:175
msgid "American Express"
msgstr ""

#: ../includes/class-wc-gateway-mondido-hw.php:176
msgid "Diners Club"
msgstr ""

#: ../includes/class-wc-gateway-mondido-hw.php:177
msgid "Direktbank"
msgstr ""

#: ../includes/class-wc-gateway-mondido-hw.php:178
msgid "Invoice/PartPayment"
msgstr ""

#: ../includes/class-wc-gateway-mondido-hw.php:179
msgid "PayPal"
msgstr ""

#: ../includes/class-wc-gateway-mondido-hw.php:180
msgid "MasterPass"
msgstr ""

#: ../includes/class-wc-gateway-mondido-hw.php:185
msgid "Text for \"Place Order\" button"
msgstr ""
Expand Down Expand Up @@ -280,10 +252,6 @@ msgstr ""
msgid "Name"
msgstr ""

#: ../templates/admin/payment-actions.php:19
msgid "Card"
msgstr ""

#: ../templates/admin/payment-actions.php:21
msgid "Status"
msgstr ""
Expand Down Expand Up @@ -346,3 +314,72 @@ msgstr ""
#: ../woocommerce-gateway-mondido.php:268
msgid "Subscription plan"
msgstr ""

msgid "MasterPass"
msgstr "MasterPass"

msgid "Direktbank"
msgstr "Direktbank"

msgid "After Pay"
msgstr "After Pay"

msgid "American Express"
msgstr "American Express"

msgid "Bank"
msgstr "Bank"

msgid "Card"
msgstr "Kort"

msgid "Diners"
msgstr "Diners"

msgid "Discover"
msgstr "Discover"

msgid "E-payment"
msgstr "E-payment"

msgid "E-Payments"
msgstr "E-Payments"

msgid "Invoice"
msgstr "Faktura"

msgid "JCB"
msgstr "JCB"

msgid "Manual Invoice"
msgstr "Manuell faktura"

msgid "Mastercard"
msgstr "Mastercard"

msgid "Mobile Pay"
msgstr "Mobile Pay"

msgid "Payment"
msgstr "Betalning"

msgid "PayPal"
msgstr "PayPal"

msgid "Recurring"
msgstr "Återkommande"

msgid "Siirto"
msgstr "Siirto"

msgid "Stored card"
msgstr "Sparat kort"

msgid "Swish"
msgstr "Swish"

msgid "Vipps"
msgstr "Vipps"

msgid "Visa"
msgstr "Visa"

0 comments on commit 450af46

Please sign in to comment.