fix display payment methods
This commit is contained in:
parent
d929a1fd5f
commit
7081b71bb2
2 changed files with 62 additions and 3 deletions
|
@ -280,15 +280,30 @@ abstract class WC_Retailcrm_Abstracts_Settings extends WC_Integration
|
|||
];
|
||||
}
|
||||
|
||||
foreach ($wc_payment->payment_gateways() as $payment) {
|
||||
foreach ($wc_payment->get_available_payment_gateways() as $payment) {
|
||||
$title = '';
|
||||
$description = '';
|
||||
|
||||
if (empty($payment->method_title)) {
|
||||
$title = $payment->id;
|
||||
} else {
|
||||
$title = $payment->method_title;
|
||||
}
|
||||
|
||||
if (empty($payment->method_description)) {
|
||||
$description = $payment->description;
|
||||
} else {
|
||||
$description = $payment->method_description;
|
||||
}
|
||||
|
||||
$this->form_fields[$payment->id] = [
|
||||
'css' => 'min-width:350px;',
|
||||
'type' => 'select',
|
||||
'title' => __($payment->method_title, 'woocommerce'),
|
||||
'title' => __($title, 'woocommerce'),
|
||||
'class' => 'select',
|
||||
'options' => $paymentsList,
|
||||
'desc_tip' => true,
|
||||
'description' => __($payment->method_description, 'woocommerce'),
|
||||
'description' => __($description, 'woocommerce'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,50 @@ class WC_Retailcrm_Abstracts_Settings_Test extends WC_Retailcrm_Test_Case_Helpe
|
|||
}
|
||||
}
|
||||
|
||||
public function test_validate_payments()
|
||||
{
|
||||
$paymentGateway = new WC_Payment_Gateways();
|
||||
|
||||
$enabledPayments = $paymentGateway->get_available_payment_gateways();
|
||||
$this->assertCount(0, $enabledPayments);
|
||||
|
||||
$payments = $paymentGateway->payment_gateways();
|
||||
$keys = array_keys($payments);
|
||||
$payments[$keys[0]]->method_title = null;
|
||||
$payments[$keys[2]]->method_description = null;
|
||||
$preparePayments = [];
|
||||
|
||||
foreach ($payments as $payment) {
|
||||
$title = '';
|
||||
$description = '';
|
||||
|
||||
if (empty($payment->method_title)) {
|
||||
$title = $payment->id;
|
||||
} else {
|
||||
$title = $payment->method_title;
|
||||
}
|
||||
|
||||
if (empty($payment->method_description)) {
|
||||
$description = $payment->description;
|
||||
} else {
|
||||
$description = $payment->method_description;
|
||||
}
|
||||
|
||||
$preparePayments[$payment->id] = [
|
||||
'css' => 'min-width:350px;',
|
||||
'type' => 'select',
|
||||
'title' => $title,
|
||||
'class' => 'select',
|
||||
'desc_tip' => true,
|
||||
'description' => $description,
|
||||
];
|
||||
}
|
||||
|
||||
$this->assertEquals($payments[$keys[0]]->id, $preparePayments[$keys[0]]['title']);
|
||||
$this->assertEquals($payments[$keys[2]]->description, $preparePayments[$keys[2]]['description']);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function dataProviderAssistant()
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue