Plugin Directory

Changeset 2651420


Ignore:
Timestamp:
12/31/2021 04:43:32 PM (4 years ago)
Author:
nfusionsolutions
Message:

2.9.9 improve multi-currency caching

Location:
precious-metals-automated-product-pricing-pro/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • precious-metals-automated-product-pricing-pro/trunk/WooCommerce_Plugin_Nfusion.php

    r2644721 r2651420  
    1111 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1212 
    13  * Version: 2.9.8
     13 * Version: 2.9.9
    1414*/
    15 define("NFS_CATALOG_PLUGIN_VERSION",   "2.9.8");
     15define("NFS_CATALOG_PLUGIN_VERSION",   "2.9.9");
    1616
    1717function nfs_catalog_plugin_tryGetProductPrice($sku){
     
    2828function nfs_catalog_plugin_get_all_products(){
    2929    $fetchRemote = false;
     30    $currency = get_woocommerce_currency();
    3031    $ttlSeconds = 60;//cache timeout in seconds
     32    $productsMapKey = 'nfs_catalog_products_all_' . $currency;
    3133    //first check cache
    32     $productsMap = get_transient('nfs_catalog_products_all');
     34    $productsMap = get_transient($productsMapKey);
    3335    if ($productsMap === false || !isset($productsMap)) {
    3436        //not found in cache, fetch from remote
     
    4547   
    4648    if ($fetchRemote === true) {
    47         $productsMap = nfs_catalog_plugin_fetch_products_from_remote();
     49        $productsMap = nfs_catalog_plugin_fetch_products_from_remote($currency);
    4850        if($productsMap !== false) {
    4951            //only cache if we got a valid response
    50             set_transient('nfs_catalog_products_all', $productsMap, $ttlSeconds);
     52            set_transient($productsMapKey, $productsMap, $ttlSeconds);
    5153        }
    5254        else {
     
    5759}
    5860
    59 function nfs_catalog_plugin_fetch_products_from_remote(){
     61function nfs_catalog_plugin_fetch_products_from_remote($currency){
    6062    if( !class_exists( 'WP_Http' ) ){
    6163        include_once( ABSPATH . WPINC. '/class-http.php' );
     
    6567    $salesChannel = get_option('nfusion_sales_channel');
    6668    $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;
    6970   
    7071    $args = array(
     
    127128 * Override the product price from woocommerce with a price from the nfusion catalog
    128129 */
    129 add_filter( 'woocommerce_product_get_price', 'nfs_catalog_plugin_price', 10, 2 );
     130add_filter( 'woocommerce_product_get_price', 'nfs_catalog_plugin_price', 10000, 2 );
    130131function nfs_catalog_plugin_price( $price, $product ){
    131132    $existing_sku = get_post_meta($product->get_id(), 'nfs_catalog_plugin_sku', true);
  • precious-metals-automated-product-pricing-pro/trunk/readme.txt

    r2644721 r2651420  
    77Tested up to: 5.8
    88Requires at least: 3.5.0
    9 Stable tag: 2.9.8
     9Stable tag: 2.9.9
    1010
    1111Automated realtime metals spot and futures data dynamically updates product prices in your store for Gold, Silver, Platinum, and Palladium
     
    130130* minor bug fixes
    131131
     132= 2.9.9 =
     133* improve multi-currency caching
     134
    132135== Upgrade Notice ==
    133136Latest Stable Version
Note: See TracChangeset for help on using the changeset viewer.