get_credential( \Airalo\Admin\Settings\Credential::CLIENT_ID ); //$sandbox_client_id = $credentials->get_credential( \Airalo\Admin\Settings\Credential::CLIENT_ID_SANDBOX ); $options = new \Airalo\Admin\Settings\Option(); $client_secret_encrypted = $options->fetch_option(\Airalo\Admin\Settings\Credential::CLIENT_SECRET); //$client_sandbox_secret_encrypted = $options->fetch_option(\Airalo\Admin\Settings\Credential::CLIENT_SECRET_SANDBOX); $auto_publish = $options->fetch_option_for_settings_page( \Airalo\Admin\Settings\Option::AUTO_PUBLISH ); $auto_publish_after_update = $options->fetch_option_for_settings_page( \Airalo\Admin\Settings\Option::AUTO_PUBLISH_AFTER_UPDATE ); //$use_sandbox = $options->fetch_option_for_settings_page(\Airalo\Admin\Settings\Option::USE_SANDBOX); $airalo_sim_name = $options->fetch_option_for_settings_page( \Airalo\Admin\Settings\Option::USE_AIRALO_SIM_NAME ); $airalo_esim_cloud_share = $options->fetch_option_for_settings_page( \Airalo\Admin\Settings\Option::USE_ESIM_CLOUD_SHARE ); $airalo_update_product_title = $options->fetch_option( \Airalo\Admin\Settings\Option::UPDATE_PRODUCT_TITLE ) !== 'off' ? 'checked' : ''; $airalo_update_product_description = $options->fetch_option( \Airalo\Admin\Settings\Option::UPDATE_PRODUCT_DESCRIPTION ) !== 'off' ? 'checked' : ''; $airalo_flush_products = $options->fetch_option( \Airalo\Admin\Settings\Option::FLUSH_PRODUCTS ) !== 'off' ? 'checked' : ''; $sync_images = $options->fetch_option( \Airalo\Admin\Settings\Option::SYNC_IMAGES ) !== 'off' ? 'checked' : ''; $last_sync = $options->fetch_option(\Airalo\Admin\Settings\Option::LAST_SYNC); $last_successful_sync = $options->fetch_option(\Airalo\Admin\Settings\Option::LAST_SUCCESSFUL_SYNC); $error = $options->fetch_option( \Airalo\Admin\Settings\Option::SYNC_ERROR ); $show_error = $error ? 'airaloShow': 'airaloHide'; $language = $options->fetch_option( \Airalo\Admin\Settings\Option::LANGUAGE ); wp_enqueue_style('airalo-admin-style', 'https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600;1,700&display=swap'); $nonce = wp_create_nonce( 'airalo-admin' ); ?>

Airalo Plugin

General

Sync Products

Last Sync:
Last Successful Sync:
Sync Error:

Settings

API Credentials


fetch_option( \Airalo\Admin\Settings\Credential::CLIENT_SECRET ); if ( $client_secret == $encrypted_secret && null != $encrypted_secret ) { $client_secret = null; } airalo_save_credentials( $client_id, $client_secret ); //$sandbox_client_id = isset( $_POST['airalo_client_id_sandbox'] ) ? sanitize_text_field( $_POST['airalo_client_id_sandbox'] ): null; //$sandbox_client_secret = isset( $_POST['airalo_client_secret_sandbox'] ) ? sanitize_text_field( $_POST['airalo_client_secret_sandbox'] ): null; //$encrypted_sandbox_secret = $options->fetch_option( \Airalo\Admin\Settings\Credential::CLIENT_SECRET_SANDBOX ); // if ( $sandbox_client_secret == $encrypted_sandbox_secret && null != $encrypted_sandbox_secret ) { // $sandbox_client_secret = null; // } //airalo_save_credentials( $sandbox_client_id, $sandbox_client_secret, true ); } } function airalo_save_settings(): void { $auto_publish = isset( $_POST['airalo_auto_publish'] ) ? sanitize_text_field( $_POST['airalo_auto_publish'] ) : 'off'; $auto_publish_after_update = isset( $_POST['airalo_auto_publish_update'] ) ? sanitize_text_field( $_POST['airalo_auto_publish_update'] ) : 'off'; // @IMPORTANT: enforce sandbox is stored as disabled in DB, some partners may have it enabled and if we hide option it will remain stuck $use_sandbox = 'off'; $language = isset( $_POST['airalo_language'] ) ? sanitize_text_field( $_POST['airalo_language'] ) : 'en'; $sync_images = isset( $_POST['airalo_sync_images'] ) ? sanitize_text_field( $_POST['airalo_sync_images'] ) : 'off'; $airalo_sim_name = isset( $_POST['airalo_sim_name'] ) ? sanitize_text_field( $_POST['airalo_sim_name'] ): 'off'; $airalo_esim_cloud_share = isset( $_POST['airalo_esim_cloud_share'] ) ? sanitize_text_field( $_POST['airalo_esim_cloud_share'] ): 'off'; $airalo_update_product_title = isset( $_POST['airalo_update_product_title'] ) ? sanitize_text_field( $_POST['airalo_update_product_title'] ): 'off'; $airalo_update_product_description = isset( $_POST['airalo_update_product_description'] ) ? sanitize_text_field( $_POST['airalo_update_product_description'] ): 'off'; $airalo_flush_products = isset( $_POST['airalo_flush_products'] ) ? sanitize_text_field( $_POST['airalo_flush_products'] ) : 'off'; $options = new \Airalo\Admin\Settings\Option(); // $use_sandbox_old = $options->fetch_option( \Airalo\Admin\Settings\Option::USE_SANDBOX ); // if ( $use_sandbox_old != $use_sandbox ) { // $options->insert_option( \Airalo\Admin\Settings\Option::ENVIRONMENT_SWITCHED, 'true' ); // } $options->insert_option( \Airalo\Admin\Settings\Option::AUTO_PUBLISH, $auto_publish ); $options->insert_option( \Airalo\Admin\Settings\Option::AUTO_PUBLISH_AFTER_UPDATE, $auto_publish_after_update ); $options->insert_option( \Airalo\Admin\Settings\Option::USE_SANDBOX, $use_sandbox ); $options->insert_option( \Airalo\Admin\Settings\Option::LANGUAGE, $language ); $options->insert_option( \Airalo\Admin\Settings\Option::SYNC_IMAGES, $sync_images ); $options->insert_option( \Airalo\Admin\Settings\Option::USE_AIRALO_SIM_NAME, $airalo_sim_name ); $options->insert_option( \Airalo\Admin\Settings\Option::USE_ESIM_CLOUD_SHARE, $airalo_esim_cloud_share ); $options->insert_option( \Airalo\Admin\Settings\Option::UPDATE_PRODUCT_TITLE, $airalo_update_product_title ); $options->insert_option( \Airalo\Admin\Settings\Option::UPDATE_PRODUCT_DESCRIPTION, $airalo_update_product_description ); $options->insert_option( \Airalo\Admin\Settings\Option::FLUSH_PRODUCTS, $airalo_flush_products ); } function airalo_save_credentials( $clientId, $clientSecret, $isSandbox = false ): void { $clientIdCredential = \Airalo\Admin\Settings\Credential::CLIENT_ID; $clientSecretCredential = \Airalo\Admin\Settings\Credential::CLIENT_SECRET; // if ( $isSandbox ) { // $clientIdCredential = \Airalo\Admin\Settings\Credential::CLIENT_ID_SANDBOX; // $clientSecretCredential = \Airalo\Admin\Settings\Credential::CLIENT_SECRET_SANDBOX; // } $credentials = new \Airalo\Admin\Settings\Credential(); if ( $clientId ) { $credentials->insert_credential( sanitize_text_field( $clientId ), $clientIdCredential ); } if ( $clientSecret ) { $credentials->insert_credential( sanitize_text_field( $clientSecret ), $clientSecretCredential ); } } function airalo_main_section_db() { echo '

Settings

'; } function airalo_settings_field_cb() { $options = get_options( 'airalo-options' ); echo '

Settings

'; } add_action( 'airalo_sync_products', 'airalo_sync_products_function', 10, 2 ); function airalo_sync_products_function() { $product_syncer = new \Airalo\Admin\Syncers\ProductSyncer(); $product_syncer->handle(); } add_filter( 'woocommerce_add_to_cart_validation', 'airalo_validate_cart_item_quantity', 10, 3 ); function airalo_validate_cart_item_quantity( $passed, $ignore_param, $quantity ) { return ( new OrderValidator() )->handle( $passed, $quantity ); } add_action( 'woocommerce_thankyou', 'airalo_submit_order', 10, 1 ); function airalo_submit_order( $order ) { $order = wc_get_order( $order ); $items = $order->get_items(); $order_items = new \Airalo\Admin\OrderItem( $items ); $airalo_order_items = $order_items->get_airalo_order_items(); // skip if no airalo order items if ( empty( $airalo_order_items ) ) { return; } ( new AiraloOrder() )->handle( $order ); } add_action( 'woocommerce_order_status_completed', 'airalo_admin_order_on_status' ); add_action( 'woocommerce_order_status_processing', 'airalo_admin_order_on_status' ); function airalo_admin_order_on_status( $order_id ) { $order = wc_get_order( $order_id ); $created_via = $order->get_created_via(); if ( $created_via != 'admin' ) { return; } if ( Cached::get( function () { // do nothing, just check if cache for this order exists }, $order->get_id() ) ) { return; } ( new AiraloOrder() )->handle( $order ); }