PATH:
var
/
softaculous
/
sitepad
/
editor
/
site-data
/
plugins
/
kkart-pro
/
includes
<?php /** * Handles storage and retrieval of shipping zones * * @package Kkart\Classes * @version 3.3.0 * @since 2.6.0 */ if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Shipping zones class. */ class KKART_Shipping_Zones { /** * Get shipping zones from the database. * * @since 2.6.0 * @param string $context Getting shipping methods for what context. Valid values, admin, json. * @return array Array of arrays. */ public static function get_zones( $context = 'admin' ) { $data_store = KKART_Data_Store::load( 'shipping-zone' ); $raw_zones = $data_store->get_zones(); $zones = array(); foreach ( $raw_zones as $raw_zone ) { $zone = new KKART_Shipping_Zone( $raw_zone ); $zones[ $zone->get_id() ] = $zone->get_data(); $zones[ $zone->get_id() ]['zone_id'] = $zone->get_id(); $zones[ $zone->get_id() ]['formatted_zone_location'] = $zone->get_formatted_location(); $zones[ $zone->get_id() ]['shipping_methods'] = $zone->get_shipping_methods( false, $context ); } return $zones; } /** * Get shipping zone using it's ID * * @since 2.6.0 * @param int $zone_id Zone ID. * @return KKART_Shipping_Zone|bool */ public static function get_zone( $zone_id ) { return self::get_zone_by( 'zone_id', $zone_id ); } /** * Get shipping zone by an ID. * * @since 2.6.0 * @param string $by Get by 'zone_id' or 'instance_id'. * @param int $id ID. * @return KKART_Shipping_Zone|bool */ public static function get_zone_by( $by = 'zone_id', $id = 0 ) { $zone_id = false; switch ( $by ) { case 'zone_id': $zone_id = $id; break; case 'instance_id': $data_store = KKART_Data_Store::load( 'shipping-zone' ); $zone_id = $data_store->get_zone_id_by_instance_id( $id ); break; } if ( false !== $zone_id ) { try { return new KKART_Shipping_Zone( $zone_id ); } catch ( Exception $e ) { return false; } } return false; } /** * Get shipping zone using it's ID. * * @since 2.6.0 * @param int $instance_id Instance ID. * @return bool|KKART_Shipping_Method */ public static function get_shipping_method( $instance_id ) { $data_store = KKART_Data_Store::load( 'shipping-zone' ); $raw_shipping_method = $data_store->get_method( $instance_id ); $kkart_shipping = KKART_Shipping::instance(); $allowed_classes = $kkart_shipping->get_shipping_method_class_names(); if ( ! empty( $raw_shipping_method ) && in_array( $raw_shipping_method->method_id, array_keys( $allowed_classes ), true ) ) { $class_name = $allowed_classes[ $raw_shipping_method->method_id ]; if ( is_object( $class_name ) ) { $class_name = get_class( $class_name ); } return new $class_name( $raw_shipping_method->instance_id ); } return false; } /** * Delete a zone using it's ID * * @param int $zone_id Zone ID. * @since 2.6.0 */ public static function delete_zone( $zone_id ) { $zone = new KKART_Shipping_Zone( $zone_id ); $zone->delete(); } /** * Find a matching zone for a given package. * * @since 2.6.0 * @uses kkart_make_numeric_postcode() * @param array $package Shipping package. * @return KKART_Shipping_Zone */ public static function get_zone_matching_package( $package ) { $country = strtoupper( kkart_clean( $package['destination']['country'] ) ); $state = strtoupper( kkart_clean( $package['destination']['state'] ) ); $postcode = kkart_normalize_postcode( kkart_clean( $package['destination']['postcode'] ) ); $cache_key = KKART_Cache_Helper::get_cache_prefix( 'shipping_zones' ) . 'kkart_shipping_zone_' . md5( sprintf( '%s+%s+%s', $country, $state, $postcode ) ); $matching_zone_id = wp_cache_get( $cache_key, 'shipping_zones' ); if ( false === $matching_zone_id ) { $data_store = KKART_Data_Store::load( 'shipping-zone' ); $matching_zone_id = $data_store->get_zone_id_from_package( $package ); wp_cache_set( $cache_key, $matching_zone_id, 'shipping_zones' ); } return new KKART_Shipping_Zone( $matching_zone_id ? $matching_zone_id : 0 ); } }
[+]
..
[+]
log-handlers
[-] class-kkart-regenerate-images.php
[edit]
[-] class-kkart-order-item-shipping.php
[edit]
[-] class-kkart-order-item-product.php
[edit]
[-] class-kkart-privacy-background-process.php
[edit]
[-] class-kkart-data-exception.php
[edit]
[+]
traits
[-] class-kkart-embed.php
[edit]
[-] class-kkart-data-store.php
[edit]
[-] kkart-coupon-functions.php
[edit]
[+]
wccom-site
[-] class-kkart-frontend-scripts.php
[edit]
[-] class-kkart-regenerate-images-request.php
[edit]
[+]
gateways
[-] class-kkart-autoloader.php
[edit]
[-] kkart-order-item-functions.php
[edit]
[-] class-kkart-webhook.php
[edit]
[-] kkart-term-functions.php
[edit]
[+]
shipping
[-] class-kkart-product-grouped.php
[edit]
[-] class-kkart-ajax.php
[edit]
[-] class-kkart-privacy-erasers.php
[edit]
[+]
admin
[-] class-kkart-tracker.php
[edit]
[-] class-kkart-order-item-fee.php
[edit]
[+]
customizer
[-] kkart-conditional-functions.php
[edit]
[-] class-kkart-tax.php
[edit]
[-] class-kkart-product-variable.php
[edit]
[+]
widgets
[-] kkart-webhook-functions.php
[edit]
[-] class-kkart-api.php
[edit]
[+]
payment-tokens
[-] premium_functions.php
[edit]
[-] class-kkart-order-refund.php
[edit]
[-] class-kkart-shipping-zone.php
[edit]
[+]
tracks
[-] class-kkart-structured-data.php
[edit]
[-] class-kkart-form-handler.php
[edit]
[-] class-kkart-emails.php
[edit]
[-] class-kkart-post-data.php
[edit]
[-] class-kkart-rest-authentication.php
[edit]
[-] class-kkart-geolite-integration.php
[edit]
[-] kkart-attribute-functions.php
[edit]
[-] class-kkart-background-emailer.php
[edit]
[-] class-kkart-shipping-zones.php
[edit]
[-] class-kkart-comments.php
[edit]
[+]
legacy
[-] class-kkart-product-variation.php
[edit]
[+]
theme-support
[+]
data-stores
[-] class-kkart-cart-session.php
[edit]
[+]
integrations
[-] class-kkart-session-handler.php
[edit]
[-] class-kkart.php
[edit]
[-] class-kkart-geolocation.php
[edit]
[-] class-kkart-discounts.php
[edit]
[-] class-kkart-payment-gateways.php
[edit]
[-] class-kkart-install.php
[edit]
[+]
abstracts
[-] class-kkart-privacy.php
[edit]
[-] kkart-page-functions.php
[edit]
[-] class-kkart-background-updater.php
[edit]
[-] class-kkart-customer-download.php
[edit]
[-] shortcodes.php
[edit]
[-] class-kkart-deprecated-action-hooks.php
[edit]
[-] kkart-order-functions.php
[edit]
[+]
walkers
[-] kkart-widget-functions.php
[edit]
[-] class-kkart-countries.php
[edit]
[-] class-kkart-payment-tokens.php
[edit]
[-] class-kkart-rate-limiter.php
[edit]
[-] class-kkart-coupon.php
[edit]
[-] body-props-settings.php
[edit]
[-] class-kkart-order-item-meta.php
[edit]
[-] class-kkart-shortcodes.php
[edit]
[-] class-kkart-auth.php
[edit]
[-] class-kkart-logger.php
[edit]
[-] class-kkart-product-simple.php
[edit]
[-] class-kkart-order-item.php
[edit]
[-] class-kkart-log-levels.php
[edit]
[-] kkart-stock-functions.php
[edit]
[-] class-kkart-checkout.php
[edit]
[+]
emails
[+]
interfaces
[-] class-kkart-customer.php
[edit]
[-] class-kkart-geo-ip.php
[edit]
[-] class-kkart-customer-download-log.php
[edit]
[+]
rest-api
[+]
cli
[-] class-kkart-integrations.php
[edit]
[-] shortcode_functions.php
[edit]
[-] kkart-template-hooks.php
[edit]
[-] class-kkart-datetime.php
[edit]
[-] class-kkart-deprecated-filter-hooks.php
[edit]
[-] class-kkart-breadcrumb.php
[edit]
[-] class-kkart-shipping-rate.php
[edit]
[-] class-kkart-order-query.php
[edit]
[+]
import
[-] kkart-rest-functions.php
[edit]
[-] kkart-notice-functions.php
[edit]
[-] class-kkart-product-query.php
[edit]
[-] class-kkart-register-wp-admin-settings.php
[edit]
[-] class-kkart-product-attribute.php
[edit]
[+]
shortcodes
[-] kkart-user-functions.php
[edit]
[-] kkart-template-functions.php
[edit]
[-] class-kkart-download-handler.php
[edit]
[-] class-kkart-validation.php
[edit]
[-] class-kkart-order-item-tax.php
[edit]
[-] class-kkart-product-external.php
[edit]
[-] kkart-formatting-functions.php
[edit]
[-] class-kkart-privacy-exporters.php
[edit]
[-] class-kkart-post-types.php
[edit]
[-] class-kkart-cli.php
[edit]
[-] class-kkart-query.php
[edit]
[-] premium.php
[edit]
[-] kkart-cart-functions.php
[edit]
[-] class-kkart-cache-helper.php
[edit]
[-] class-kkart-https.php
[edit]
[-] kkart-core-functions.php
[edit]
[-] template.php
[edit]
[-] class-kkart-order-factory.php
[edit]
[+]
libraries
[-] class-kkart-cart.php
[edit]
[-] class-kkart-meta-data.php
[edit]
[-] kkart-account-functions.php
[edit]
[-] class-kkart-order-item-coupon.php
[edit]
[-] class-kkart-cart-totals.php
[edit]
[-] class-kkart-template-loader.php
[edit]
[+]
queue
[-] class-kkart-cart-fees.php
[edit]
[-] class-kkart-shipping.php
[edit]
[-] class-kkart-product-factory.php
[edit]
[+]
export
[-] class-kkart-product-download.php
[edit]
[-] kkart-product-functions.php
[edit]
[-] class-kkart-order.php
[edit]
[-] kkart-update-functions.php
[edit]
[-] class-kkart-rest-exception.php
[edit]