bind_core_events(); } /** * Get instance of plugin core class. * * @return P24_Core|null */ function get_przelewy24_plugin_instance() { return apply_filters( 'przelewy24_plugin_instance', null ); } /** * Get list of available currencies. * * If multi currency is not activated, the null will be returned. * * @return array|null */ function get_przelewy24_multi_currency_options() { return apply_filters( 'przelewy24_multi_currency_options', null ); } /** * add_action. */ function woocommerce_p24_add_gateway($methods) { $methods[] = 'WC_Gateway_Przelewy24'; return $methods; } function my_stored_cards() { $gateway = new WC_Gateway_Przelewy24(); if ( ! $gateway->get_settings_from_internal_formatted()->access_mode_to_strict()->get_p24_oneclick() ) { return; } $t['my_cards'] = __('Moje zapisane karty', 'przelewy24'); $t['are_you_sure'] = __('Czy jesteś pewien?', 'przelewy24'); $t['delete_card'] = __('Usuń kartę', 'przelewy24'); $t['cc_forget'] = __('Nie pamiętaj moich kart', 'przelewy24'); $t['no_cards'] = __('Brak zapamiętanych kart płatniczych', 'przelewy24'); $t['save'] = __('Zapisz', 'przelewy24'); if (isset($_GET['cardrm']) && (int)$_GET['cardrm'] > 0) { WC_Gateway_Przelewy24::del_card(get_current_user_id(), (int)$_GET['cardrm']); } if (isset($_POST['act']) && 'cc_forget' === $_POST['act']) { WC_Gateway_Przelewy24::set_cc_forget( get_current_user_id(), isset( $_POST['cc_forget'] ) && '1' === $_POST['cc_forget'] ); if (isset($_POST['cc_forget']) && '1' === $_POST['cc_forget']) { $all_cards = WC_Gateway_Przelewy24::get_all_cards(get_current_user_id()); if (is_array($all_cards)) { foreach ($all_cards as $item) { WC_Gateway_Przelewy24::del_card(get_current_user_id(), (int)$item->id); } } } } $cc_forget_checked = WC_Gateway_Przelewy24::get_cc_forget(get_current_user_id()) ? ' checked="checked" ' : ''; $all_cards = WC_Gateway_Przelewy24::get_all_cards(get_current_user_id()); echo <<{$t['my_cards']}
HTML; if (is_array($all_cards) && sizeof($all_cards) > 0) { foreach ($all_cards as $item) { $ccard = $item->custom_value; $ccard['exp'] = substr($ccard['exp'], 0, 2) . '/' . substr($ccard['exp'], 2); $link = '?' . http_build_query(array('cardrm' => $item->id) + $_GET); echo <<
{$ccard['mask']}
{$ccard['exp']}
{$t['delete_card']}