/
cards.php
62 lines (49 loc) · 1.74 KB
/
cards.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/*
$Id$
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2014 osCommerce
Released under the GNU General Public License
*/
class OSCOM_PayPal_DP_Cfg_cards {
var $default = 'visa;mastercard;discover;amex;maestro';
var $title;
var $description;
var $sort_order = 200;
var $cards = ['visa' => 'Visa', 'mastercard' => 'MasterCard', 'discover' => 'Discover Card', 'amex' => 'American Express', 'maestro' => 'Maestro'];
function __construct() {
global $OSCOM_PayPal;
$this->title = $OSCOM_PayPal->getDef('cfg_dp_cards_title');
$this->description = $OSCOM_PayPal->getDef('cfg_dp_cards_desc');
}
function getSetField() {
$active = explode(';', OSCOM_APP_PAYPAL_DP_CARDS);
$input = null;
foreach ( $this->cards as $key => $value ) {
$input .= '<div class="custom-control custom-checkbox custom-control-inline">';
$input .= '<input type="checkbox" class="custom-control-input" id="cardsSelection' . ucfirst($key) . '" name="card_types[]" value="' . $key . '"' . (in_array($key, $active) ? ' checked="checked"' : '') . '>';
$input .= '<label class="custom-control-label" for="cardsSelection' . ucfirst($key) . '">' . $value . '</label>';
$input .= '</div>';
}
$result = <<<EOT
<h5>{$this->title}</h5>
<p>{$this->description}</p>
<div class="mb-3" id="cardsSelection">
{$input}
<input type="hidden" name="cards" value="" />
</div>
<script>
$(function() {
$('form[name="paypalConfigure"]').submit(function() {
$('input[name="cards"]').val($('input[name="card_types[]"]:checked').map(function() {
return this.value;
}).get().join(';'));
});
});
</script>
EOT;
return $result;
}
}
?>