Changeset 2651420
- Timestamp:
- 12/31/2021 04:43:32 PM (4 years ago)
- Location:
- precious-metals-automated-product-pricing-pro/trunk
- Files:
-
- 2 edited
-
WooCommerce_Plugin_Nfusion.php (modified) (6 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
precious-metals-automated-product-pricing-pro/trunk/WooCommerce_Plugin_Nfusion.php
r2644721 r2651420 11 11 * License URI: https://www.gnu.org/licenses/gpl-2.0.html 12 12 13 * Version: 2.9. 813 * Version: 2.9.9 14 14 */ 15 define("NFS_CATALOG_PLUGIN_VERSION", "2.9. 8");15 define("NFS_CATALOG_PLUGIN_VERSION", "2.9.9"); 16 16 17 17 function nfs_catalog_plugin_tryGetProductPrice($sku){ … … 28 28 function nfs_catalog_plugin_get_all_products(){ 29 29 $fetchRemote = false; 30 $currency = get_woocommerce_currency(); 30 31 $ttlSeconds = 60;//cache timeout in seconds 32 $productsMapKey = 'nfs_catalog_products_all_' . $currency; 31 33 //first check cache 32 $productsMap = get_transient( 'nfs_catalog_products_all');34 $productsMap = get_transient($productsMapKey); 33 35 if ($productsMap === false || !isset($productsMap)) { 34 36 //not found in cache, fetch from remote … … 45 47 46 48 if ($fetchRemote === true) { 47 $productsMap = nfs_catalog_plugin_fetch_products_from_remote( );49 $productsMap = nfs_catalog_plugin_fetch_products_from_remote($currency); 48 50 if($productsMap !== false) { 49 51 //only cache if we got a valid response 50 set_transient( 'nfs_catalog_products_all', $productsMap, $ttlSeconds);52 set_transient($productsMapKey, $productsMap, $ttlSeconds); 51 53 } 52 54 else { … … 57 59 } 58 60 59 function nfs_catalog_plugin_fetch_products_from_remote( ){61 function nfs_catalog_plugin_fetch_products_from_remote($currency){ 60 62 if( !class_exists( 'WP_Http' ) ){ 61 63 include_once( ABSPATH . WPINC. '/class-http.php' ); … … 65 67 $salesChannel = get_option('nfusion_sales_channel'); 66 68 $token = get_option('nfusion_api_token'); 67 $cur_currency = get_woocommerce_currency(); 68 $catalogUrl = 'https://'.$tenantAlias.'.nfusioncatalog.com/service/price/pricesbychannel?currency='.$cur_currency.'&channel='.$salesChannel.'&withretailtiers=true&token='.$token; 69 $catalogUrl = 'https://'.$tenantAlias.'.nfusioncatalog.com/service/price/pricesbychannel?currency='.$currency.'&channel='.$salesChannel.'&withretailtiers=true&token='.$token; 69 70 70 71 $args = array( … … 127 128 * Override the product price from woocommerce with a price from the nfusion catalog 128 129 */ 129 add_filter( 'woocommerce_product_get_price', 'nfs_catalog_plugin_price', 10 , 2 );130 add_filter( 'woocommerce_product_get_price', 'nfs_catalog_plugin_price', 10000, 2 ); 130 131 function nfs_catalog_plugin_price( $price, $product ){ 131 132 $existing_sku = get_post_meta($product->get_id(), 'nfs_catalog_plugin_sku', true); -
precious-metals-automated-product-pricing-pro/trunk/readme.txt
r2644721 r2651420 7 7 Tested up to: 5.8 8 8 Requires at least: 3.5.0 9 Stable tag: 2.9. 89 Stable tag: 2.9.9 10 10 11 11 Automated realtime metals spot and futures data dynamically updates product prices in your store for Gold, Silver, Platinum, and Palladium … … 130 130 * minor bug fixes 131 131 132 = 2.9.9 = 133 * improve multi-currency caching 134 132 135 == Upgrade Notice == 133 136 Latest Stable Version
Note: See TracChangeset
for help on using the changeset viewer.