Current Path: > home > codekrsu > > ameliagraphics.com > wp-content > plugins > pinterest-for-woocommerce > src > >
Operation : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64 Software : Apache Server IP : 162.0.232.56 | Your IP: 216.73.216.111 Domains : 1034 Domain(s) Permission : [ 0755 ]
Name | Type | Size | Last Modified | Actions |
---|---|---|---|---|
API | Directory | - | - | |
Admin | Directory | - | - | |
Exception | Directory | - | - | |
MultichannelMarketing | Directory | - | - | |
Notes | Directory | - | - | |
Product | Directory | - | - | |
Tracking | Directory | - | - | |
Utilities | Directory | - | - | |
View | Directory | - | - | |
AdCredits.php | File | 8406 bytes | August 26 2024 16:35:44. | |
AdCreditsCoupons.php | File | 1461 bytes | August 26 2024 16:35:44. | |
AdsCreditCurrency.php | File | 1946 bytes | May 20 2025 15:25:46. | |
Billing.php | File | 4901 bytes | August 26 2024 16:35:44. | |
CommerceIntegration.php | File | 7185 bytes | December 04 2024 18:47:06. | |
Compat.php | File | 952 bytes | November 16 2021 18:14:38. | |
Crypto.php | File | 3718 bytes | June 23 2025 21:16:30. | |
FeedFileOperations.php | File | 4680 bytes | August 26 2024 16:35:44. | |
FeedGenerator.php | File | 22733 bytes | August 26 2024 16:35:44. | |
FeedRegistration.php | File | 7230 bytes | December 04 2024 18:47:06. | |
FeedStatusService.php | File | 20815 bytes | March 18 2025 17:31:36. | |
Feeds.php | File | 13838 bytes | December 04 2024 18:47:06. | |
Heartbeat.php | File | 1882 bytes | October 23 2024 17:23:10. | |
LocalFeedConfigs.php | File | 3327 bytes | September 24 2024 11:32:30. | |
LocaleMapper.php | File | 3167 bytes | March 18 2025 17:31:36. | |
Logger.php | File | 3132 bytes | August 26 2024 16:35:44. | |
Merchants.php | File | 6575 bytes | September 24 2024 11:32:30. | |
PinterestApiException.php | File | 2767 bytes | December 04 2024 18:47:06. | |
PinterestShippingZone.php | File | 7161 bytes | February 16 2022 03:57:48. | |
PinterestSyncSettings.php | File | 3016 bytes | August 26 2024 16:35:44. | |
PluginActivate.php | File | 785 bytes | June 18 2022 00:23:22. | |
PluginHelper.php | File | 2537 bytes | October 11 2022 17:51:18. | |
PluginUpdate.php | File | 11166 bytes | May 29 2025 17:27:42. | |
ProductFeedStatus.php | File | 4453 bytes | August 26 2024 16:35:44. | |
ProductSync.php | File | 6351 bytes | September 24 2024 11:32:30. | |
ProductsXmlFeed.php | File | 17527 bytes | February 11 2025 16:39:50. | |
RefreshToken.php | File | 3769 bytes | August 26 2024 16:35:44. | |
RichPins.php | File | 9177 bytes | August 26 2024 16:35:44. | |
SaveToPinterest.php | File | 3525 bytes | April 26 2023 13:47:12. | |
Shipping.php | File | 8372 bytes | February 16 2022 03:57:48. | |
TrackerSnapshot.php | File | 2574 bytes | August 26 2024 16:35:44. | |
Tracking.php | File | 7488 bytes | August 29 2024 22:54:16. | |
WPConsentAPI.php | File | 1178 bytes | June 16 2025 21:44:24. | |
error_log | File | 260 bytes | June 23 2025 21:16:32. |
<?php /** * Utility class used by the Feed generation to create the shipping column. * * @package Pinterest * @since 1.0.5 */ namespace Automattic\WooCommerce\Pinterest; defined( 'ABSPATH' ) || exit; use \WC_Data_Store; /** * Shipping class. * Supported features: * - Free shipping without additional settings. * - Free shipping with minimum order value. Minimum is tested over single item product. ( still, better than nothing ) * - Flat rate shipping without additional settings. * - Flat rate with classes: no shipping class and regular classes. * - Shipping zone locations: single country, country + state, continent ( zip codes are not allowed). * - Locations mixing: continent + country + state. * - Taxes for shipping global. * - Taxes for shipping for specific country. * - Filtering of not supported countries. * - Simple products. * - Variable products. * * @since 1.0.5 */ class Shipping { /** * Local cache of shipping zones defined in WC settings. * * @var array|null $shipping_zones */ private static $shipping_zones = null; /** * Prepare shipping information for $product. * * @since 1.0.5 * * @param WC_Product $product Product for which we want to generate the shipping column. * @return array Shipping information $product. */ public function prepare_shipping_info( $product ) { $info = array(); /** * Just to be sure that we are not obstructing the feed generation with shipping column calculation errors. * Catch everything and log. This is a safety measure for unpredicted behavior. */ try { $shipping_zones = self::get_shipping_zones(); foreach ( $shipping_zones as $zone ) { $shipping_info = $zone->get_locations_with_shipping(); if ( is_null( $shipping_info ) ) { // No valid location in this shipping zone. Skip to the next zone. continue; } foreach ( $shipping_info['locations'] as $location ) { $best_shipping = self::get_best_shipping_with_cost( $location, $shipping_info['shipping_methods'], $product ); if ( null === $best_shipping ) { // No valid shipping cost for $location. Skip to the next shipping destination. continue; } $entry = array( 'country' => $location['country'], 'state' => $location['state'], 'name' => $best_shipping['name'], 'cost' => $best_shipping['cost'], ); // Build shipping entry. $info[] = $entry; } } } catch ( \Throwable $th ) { Logger::log( sprintf( // translators: 1: error message. esc_html__( "There was an error in shipping information generation for the feed file:\n%s", 'pinterest-for-woocommerce' ), $th->getMessage() ) ); } return $info; } /** * Get shipping zones defined in WooCommerce settings. * Cache for efficiency - this information will not change between different products. * * @since 1.0.5 * * @return array Shipping zones. */ private static function get_shipping_zones() { if ( null !== self::$shipping_zones ) { return self::$shipping_zones; } $data_store = WC_Data_Store::load( 'shipping-zone' ); $raw_zones = $data_store->get_zones(); self::$shipping_zones = array(); foreach ( $raw_zones as $raw_zone ) { self::$shipping_zones[] = new PinterestShippingZone( $raw_zone ); } return self::$shipping_zones; } /** * Function used for the woocommerce_shipping_free_shipping_is_available filter. * This is added to verify if min_amount feature has met the free shipping criteria. * Normally this would be done by checking values in cart. Because we are not operating on cart we filter out * this value ourselves. * * @since 1.0.5 * * @param bool $is_available Wether this shipping method should be available. * @param array $package Shipping package. * @param WC_Shipping_Free_Shipping $shipping_method Shipping method. * @return boolean */ public static function is_free_shipping_available( $is_available, $package, $shipping_method ) { if ( $is_available ) { return $is_available; } if ( ! in_array( $shipping_method->requires, array( 'min_amount' ), true ) ) { return $is_available; } $has_met_min_amount = $package['cart_subtotal'] >= $shipping_method->min_amount; return $has_met_min_amount; } /** * Get the lowest possible shipping cost for given location and shipping methods for that location. * * @since 1.0.5 * * @param array $shipping_location Country and state values of the location. * @param array $shipping_methods List of shippings methods we use to calculate the best rate. * @param WC_Product $product Product for which we want to generate the shipping column. * @return array|null Name and cost for the best found rate or null in case nothing was found. */ private static function get_best_shipping_with_cost( $shipping_location, $shipping_methods, $product ) { // Since in a shipping zone all locations are treated the same we will perform the calculations for the first one. $package = self::put_product_into_a_shipping_package( $product, $shipping_location ); $rates = array(); // Substitute default customer location and billing for. WC()->customer = new \WC_Customer( get_current_user_id() ); WC()->customer->set_billing_location( $shipping_location['country'], $shipping_location['state'] ); WC()->customer->set_shipping_location( $shipping_location['country'], $shipping_location['state'] ); // By using the filter we can trick the get_rates_for_package to continue calculations even without having the Cart defined. add_filter( 'woocommerce_shipping_free_shipping_is_available', array( static::class, 'is_free_shipping_available' ), 10, 3 ); foreach ( $shipping_methods as $shipping_method ) { $rates += $shipping_method->get_rates_for_package( $package ); } remove_filter( 'woocommerce_shipping_free_shipping_is_available', array( static::class, 'is_free_shipping_available' ), 10 ); // Check if shipping methods have returned any valid rates. if ( empty( $rates ) ) { return null; } $best_rate = self::calculate_best_rate( $rates ); return $best_rate; } /** * Pick the best rate from an array of rates. * * @since 1.0.5 * * @param array $rates List of shipping rates. * @return array Name and cost for the best found rate or null in case nothing was found. */ private static function calculate_best_rate( $rates ) { $best_cost = INF; $best_name = ''; foreach ( $rates as $rate ) { $shipping_cost = (float) $rate->get_cost(); $shipping_tax = (float) $rate->get_shipping_tax(); $total_cost = $shipping_cost + $shipping_tax; if ( $total_cost < $best_cost ) { $best_cost = $total_cost; $best_name = $rate->get_label(); } } if ( INF === $best_cost ) { return null; } return array( 'cost' => wc_format_decimal( $best_cost, 2 ), 'name' => $best_name, ); } /** * Helper function that packs products into a package structure required by the shipping methods. * * @since 1.0.5 * * @param WC_Product $product Product to package. * @param array $location Product destination location. * @return array Product packed into a package for use by shipping methods. */ public static function put_product_into_a_shipping_package( $product, $location ) { $cart_item = array( 'key' => 0, 'product_id' => $product->get_id(), 'variation_id' => null, 'variation' => null, 'quantity' => 1, 'data' => $product, 'data_hash' => wc_get_cart_item_data_hash( $product ), 'line_total' => wc_remove_number_precision( (float) $product->get_price() ), ); return array( 'contents' => array( $cart_item ), 'contents_cost' => (float) $product->get_price(), 'applied_coupons' => array(), 'user' => array( 'ID' => get_current_user_id(), ), 'destination' => array( 'country' => $location['country'], 'state' => $location['state'], 'postcode' => '', // May be used in the future. 'city' => '', 'address' => '', 'address_1' => '', 'address_2' => '', ), 'cart_subtotal' => (float) $product->get_price(), ); } }
SILENT KILLER Tool