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['type']}

{$ccard['mask']}

{$ccard['exp']}

{$t['delete_card']}
HTML; } } else { echo "
{$t['no_cards']}
"; } echo << HTML; } add_action('woocommerce_after_my_account', 'my_stored_cards'); function woocommerce_p24_action_add($actions) { global $theorder; if(!$theorder->is_paid() && $theorder->get_payment_method() === 'przelewy24') { $actions['wc_przelewy24_email_action'] = __('Wyślij e-mail do płatności przez Przelewy24', 'przelewy24'); } return $actions; } function woocommerce_p24_email_filter($email_filters){ $email_filters[] = 'woocommerce_order_action_wc_przelewy24_email_action'; return $email_filters; } /** * Sends email about order status (order is passed directly as argument). * * @param WC_Order|null $order WooCommerce order object (nullable). Function will not send email, when null is passed. */ function woocommerce_p24_email_send_order_payment_reminder( $order ) { require_once( 'includes/Przelewy24Mailer.class.php' ); $mailer = new Przelewy24Mailer(); $mailer->trigger( $order ); } /** * Sends email about order status (order is found by its id). * * @param int $order_id */ function woocommerce_p24_email_send_order_created_notification( $order_id ) { require_once( 'includes/Przelewy24Mailer.class.php' ); $mailer = new Przelewy24Mailer(); $mailer->send_order_summary_mail( new WC_Order( $order_id ) ); } function php_soap_extension_error() { echo '
' . __("Wtyczka Przelewy24 jest nieaktywna, ponieważ brakuje rozszerzenia PHP-SOAP.", "przelewy24") . '
'; } function php_curl_extension_error() { echo '
' . __("Wtyczka Przelewy24 jest nieaktywna, ponieważ brakuje rozszerzenia PHP-CURL.", "przelewy24") . '
'; } function woocommerce_not_installed_error() { echo '
' . __("Wtyczka Przelewy24 jest nieaktywna, najpierw musi być zainstalowana i aktywna wtyczka WooCommerce.", "przelewy24") . '
'; } function woocommerce_version_error() { echo '
' . __("Wtyczka Przelewy24 jest nieaktywna, ponieważ nie znaleziono odpowiedniej wersji WooCommerce.", "przelewy24") . '
'; } function check_woocommerce_version_compatibility($min, $max) { return (version_compare(WOOCOMMERCE_VERSION, $min, ">=") && version_compare(WOOCOMMERCE_VERSION, $max, "<")); }