Forum Replies Created

Viewing 15 replies - 1 through 15 (of 106 total)
  • Thread Starter tictok

    (@tictok)

    okay, solved. With a little shame and embaressment, but leaving this here in case it helps anyone else….

    Blocks were hidden in the Gutenberg/Block builder preferences. Guess I must have had Kadence installed sometime previously!

    hey @wpcentrics, ahhh, yeah, you’re right, nice spot!

    Shows why testing different scenarios is important. Thanks.

    updated to include order edit scenario. Works for me:

    /**
    * Load JavaScript for our administration
    * UPDATED TO WORK WITH HPOS
    */
    add_action('admin_enqueue_scripts', function() {
    global $pagenow;

    if (is_admin() && (
    (in_array($pagenow, ['post.php', 'post-new.php']) &&
    ($_GET['post_type'] ?? 'shop_order') === 'shop_order') ||
    ($pagenow === 'admin.php' && isset($_GET['page']) && $_GET['page'] === 'wc-orders' && isset($_GET['action']) && in_array($_GET['action'], ['new', 'edit']))
    )) {
    wp_enqueue_script('shipping-calc_js', plugins_url('js/admin-shipping-calc.js', __FILE__));
    wp_localize_script('shipping-calc_js', 'shipping_calc', array(
    'url' => admin_url('admin-ajax.php'),
    'nonce' => wp_create_nonce('admin_shipping_calculate')
    )
    );
    }
    });


    p.s. I didn’t see your solution when I posted… only a minute apart! Not come across Fish and Ships before, I’ll check it out. I’m using this with Tree Table Rate Shipping (TRS).

    EDIT:// Kind of wrong thread, but just seen your video. Fish and Ships looks good. Think I’ll give it ago. Assuming I can create parent rules based on postcode? Thanks

    I just came here to say I’d found a solution as had hit the same issue… and then saw your post. Nearly identical solution to yours. Setup to work for both HPOS and old CPT orders

    /**
    * Load JavaScript for our administration
    */
    add_action('admin_enqueue_scripts', function() {
    global $pagenow;

    if (is_admin() && (
    in_array($pagenow, ['post.php', 'post-new.php']) &&
    ($_GET['post_type'] ?: 'shop_order') === 'shop_order' ||
    ($pagenow === 'admin.php' && isset($_GET['page']) && $_GET['page'] === 'wc-orders' && isset($_GET['action']) && $_GET['action'] === 'new')
    )) {
    wp_enqueue_script('shipping-calc_js', plugins_url('js/admin-shipping-calc.js', __FILE__));
    wp_localize_script('shipping-calc_js', 'shipping_calc', array(
    'url' => admin_url('admin-ajax.php'),
    'nonce' => wp_create_nonce('admin_shipping_calculate')
    )
    );
    }
    });
    • This reply was modified 4 months, 1 week ago by tictok.

    Bump.

    Any info, either way, would be really useful

    thanks

    Thread Starter tictok

    (@tictok)

    Hi, After further testing I have discovered that it looks like whether the Purchase event gets sent or not depends upon the browser being used.

    The Purchase event does get sent by your plugin if using Chrome. However, the Purchase event is not triggered when using Safari (17.2.1 macOS Sonoma 14.2.1). Will test other browsers too.

    I discovered this as had started to add my own JS script to the order-received page to send a Purchase event to the data layer. It worked as expected (when testing in Safari) but noticed when I tested in Chrome that two purchase events where being sent.

    Disabling my own script left just the single correct purchase event being added to the data layer in Chrome. But unfortunately still nothing in Safari.

    In the meantime, is there any way do disable your (gtm4wp) purchase event so that I can consistently/reliably send my own? I understand the data should look something like the following (depending upon products, price etc):

      event: "purchase",
      ecommerce: {
        currency: "GBP",
        transaction_id: "RJG-167656",
        affiliation: "",
        value: 1,
        tax: 0.17,
        shipping: 0,
        coupon: "",
        items: [
          {
            item_id: "ABCDE",
            item_name: "Test ABCDE",
            sku: "ABCDE",
            price: 1,
            stocklevel: null,
            stockstatus: "instock",
            google_business_vertical: "retail",
            item_category: "Planting & Feeding",
            id: "ABCDE",
            quantity: 1
          }
        ]
      }


    If using Enhanced tracking do I need to include any user provider data in that payload, or will the data already in the data layer suffice?

    Many thanks
    Stef

    HI – apologies for jumping on the thread but also experiencing the same issue.

    Completely fresh GTM container after upgrading to latest version on GTM4WP.

    Stripe gateway.

    The is no ‘purchase’ event fired on either checkout or order received page and therefore my conversion tags are not being triggered.

    Trying the “Do not flag orders as being tracked” option did not change anything for me.

    The last event I can see in the data layer on checkout is “add_payment_info”.

    And on the order received page the event is: “gtm.load”. The data layers correctly contains all the order data, customer data, some payment details etc, but no purchase events.


    Thread Starter tictok

    (@tictok)

    Hiya James

    When Redis Object Cache Pro (https://objectcache.pro) detects that object-cache.php is not it’s own, the cache is disabled and the drop-in (object-cache.php) reported as invalid. It doesn’t suggest replacing object-cache.php.

    However, there is a button to enable the object cache again.

    Screenshot: https://snipboard.io/fjVKcY.jpg

    Clicking this replaces object-cache.php with its own version of the file, and the drop-in is temporarily reported as being Valid again.

    Unfortunately, it looks like the Performance plugin quickly replaces the object-cache.php file with it’s own again –?once again disabling the cache and reporting as invalid.

    FYI, the other options and feature of the Redis Cache Pro plugin are also disabled… it’s not just a visual indicator.

    Hope that helps, but do let me know if I can share any more info

    Thanks

    Thread Starter tictok

    (@tictok)

    Hey James – many thanks for the info. All makes sense.

    This led me to investigate the Object Cache Pro plugin a little further.

    It appears to have a strict check (using get_plugin_data()) to see if the metadata at the top of the object-cache.php file matches what it expects (checking against it’s own copy of the file). Therefore, unfortunately, despite the include/require at the bottom of your plugin’s object-cache.php (which I guess would work in the majority of scenarios), the metadata at the top of your object-cache.php doesn’t match, causing Redis object cache Pro to flag the object-cache.php as invalid and disables itself.

    Suspect you will consider this as an edge-case, but thought I’d share anyway.

    Many thanks.

    Thread Starter tictok

    (@tictok)

    HI – thanks or getting back to me.

    To answer your query, yes, the object-cache-plst-orig.php backup file is created.

    The order the plugins are activated in doesn’t appear to make any difference. The object-cache.php file that Object Cache Pro creates always gets overwritten by the performance plugin, resulting in Object Cache Pro reporting an Invalid drop-in file.

    In case it’s of any help…

    Contents of Performance plugins object-cache.php :

    <?php
    
    /**
    
    * Object cache drop-in from Performance Lab plugin.
    
    *
    
    * This drop-in is used, admittedly as a hack, to be able to measure server
    
    * timings in WordPress as early as possible. Once a plugin is loaded, it is
    
    * too late to capture several critical events.
    
    *
    
    * This file respects any real object cache implementation the site may already
    
    * be using, and it is implemented in a way that there is no risk for breakage.
    
    *
    
    * If you do not want the Performance Lab plugin to place this file and thus be
    
    * limited to server timings only from after plugins are loaded, you can remove
    
    * this file and set the following constant (e.g. in wp-config.php):
    
    *
    
    * define( 'PERFLAB_DISABLE_OBJECT_CACHE_DROPIN', true );
    
    *
    
    * @package performance-lab
    
    * @since 1.8.0
    
    */
    
    // Set constant to be able to later check for whether this file was loaded.
    
    define( 'PERFLAB_OBJECT_CACHE_DROPIN_VERSION', 1 );
    
    /**
    
    * Loads the Performance Lab Server-Timing API if available.
    
    *
    
    * This function will short-circuit if the constant
    
    * 'PERFLAB_DISABLE_OBJECT_CACHE_DROPIN' is set as true.
    
    *
    
    * @since 1.8.0
    
    */
    
    function perflab_load_server_timing_api_from_dropin() {
    
    if ( defined( 'PERFLAB_DISABLE_OBJECT_CACHE_DROPIN' ) && PERFLAB_DISABLE_OBJECT_CACHE_DROPIN ) {
    
    return;
    
    }
    
    $plugins_dir = defined( 'WP_PLUGIN_DIR' ) ? WP_PLUGIN_DIR : WP_CONTENT_DIR . '/plugins';
    
    $plugin_dir = $plugins_dir . '/performance-lab/';
    
    if ( ! file_exists( $plugin_dir . 'server-timing/load.php' ) ) {
    
    $plugin_dir = $plugins_dir . '/performance/';
    
    if ( ! file_exists( $plugin_dir . 'server-timing/load.php' ) ) {
    
    return;
    
    }
    
    }
    
    require_once $plugin_dir . 'server-timing/class-perflab-server-timing-metric.php';
    
    require_once $plugin_dir . 'server-timing/class-perflab-server-timing.php';
    
    require_once $plugin_dir . 'server-timing/load.php';
    
    require_once $plugin_dir . 'server-timing/defaults.php';
    
    }
    
    perflab_load_server_timing_api_from_dropin();
    
    // Load the original object cache drop-in if present.
    
    if ( file_exists( WP_CONTENT_DIR . '/object-cache-plst-orig.php' ) ) {
    
    require_once WP_CONTENT_DIR . '/object-cache-plst-orig.php';
    
    }

    Contents of object-cache-plst-orig.php (backup of object cache pro’s file):

    <?php
    
    /*
    
    * Plugin Name: Object Cache Pro (Drop-in)
    
    * Plugin URI: https://objectcache.pro
    
    * Description: A business class Redis object cache backend for WordPress.
    
    * Version: 1.17.0
    
    * Author: Rhubarb Group
    
    * Author URI: https://rhubarb.group
    
    * License: Proprietary
    
    * Requires PHP: 7.2
    
    */
    
    defined('ABSPATH') || exit;
    
    if (version_compare(PHP_VERSION, '7.2', '<')) {
    
    return require_once ABSPATH . WPINC . '/cache.php';
    
    }
    
    if (defined('WP_REDIS_DISABLED') && WP_REDIS_DISABLED) {
    
    return;
    
    }
    
    if (! empty(getenv('WP_REDIS_DISABLED'))) {
    
    return;
    
    }
    
    foreach ([
    
    defined('WP_REDIS_DIR') ? WP_REDIS_DIR : null,
    
    // Redis Cache Pro
    
    defined('WPMU_PLUGIN_DIR') ? WPMU_PLUGIN_DIR . '/redis-cache-pro' : null,
    
    defined('WP_CONTENT_DIR') ? WP_CONTENT_DIR . '/mu-plugins/redis-cache-pro' : null,
    
    defined('WP_PLUGIN_DIR') ? WP_PLUGIN_DIR . '/redis-cache-pro' : null,
    
    defined('WP_CONTENT_DIR') ? WP_CONTENT_DIR . '/plugins/redis-cache-pro' : null,
    
    // Object Cache Pro
    
    defined('WPMU_PLUGIN_DIR') ? WPMU_PLUGIN_DIR . '/object-cache-pro' : null,
    
    defined('WP_CONTENT_DIR') ? WP_CONTENT_DIR . '/mu-plugins/object-cache-pro' : null,
    
    defined('WP_PLUGIN_DIR') ? WP_PLUGIN_DIR . '/object-cache-pro' : null,
    
    defined('WP_CONTENT_DIR') ? WP_CONTENT_DIR . '/plugins/object-cache-pro' : null,
    
    ] as $path) {
    
    if ($path === null || ! is_readable("{$path}/api.php")) {
    
    continue;
    
    }
    
    if (include_once "{$path}/api.php") {
    
    return;
    
    }
    
    }
    
    error_log('objectcache.critical: Failed to locate and load object cache API');
    
    $GLOBALS['wp_object_cache_errors'] = ['Failed to locate and load object cache API'];
    
    if (defined('WP_DEBUG') && WP_DEBUG) {
    
    throw new RuntimeException('Failed to locate and load object cache API');
    
    }

    For what it’s worth, I’ve been using define( 'PERFLAB_DISABLE_OBJECT_CACHE_DROPIN', true );?in wp-config.php for ac couple of days now. object-cache.php not overwritten and object-cache-plst-orig.php not created. I realise I’ll likely be missing some server timing reporting in WooCommerce status due to this.

    Off to checkout the the links you’ve shared…

    Many thanks

    Thread Starter tictok

    (@tictok)

    Further update:

    Just found the PERFLAB_DISABLE_OBJECT_CACHE_DROPIN constant.

    Setting define( 'PERFLAB_DISABLE_OBJECT_CACHE_DROPIN', true ); in wp-config.php seems to do the trick and stops Performance Lab replacing object-cache.php

    Better than removing the action as in post above?

    Thanks

    • This reply was modified 1 year, 9 months ago by tictok.
    • This reply was modified 1 year, 9 months ago by tictok.
    Thread Starter tictok

    (@tictok)

    //EDIT: I might have found a way around it for now.

    I noticed the Performance Lab plugin, within load.php, there is a function perflab_maybe_set_object_cache_dropin() added by an action. This function appears to rename (backup) the existing object-cache.php file and replaces it with it’s own, which Redis Object Cache Pro doesn’t like.

    Removing the action that runs perflab_maybe_set_object_cache_dropin() function seems to be a work-around for now, but not sure of any consequences?

    I added remove_action( 'admin_init', 'perflab_maybe_set_object_cache_dropin' ); in my theme’s functions.php to do this.

    Thread Starter tictok

    (@tictok)

    Hi @thongnguyenminh – Wow, that was quick! thanks so much, I really appreciate it.

    Tested and confirmed working ??

    Thanks again!

    Hi there, Please consider updating the plugin to make submitting names optional!

    We have a very simple signup form in site footer and in a pop up with no data capture other than email address.

    Thank you.

    Thread Starter tictok

    (@tictok)

    Hi there Aurovrata –

    In the example yesterday there was nothing out of the ordinary. No special queries (un-modified/fresh templates), no plugins, default wordpress theme, empty functions.php.

    I wonder if your plugin no longer works with WooCommerce product categories, but I believe they’re really just a standard custom taxonomy.

    A couple of the product categories do have hierarchy… i.e a few categories are children of a parent category.

    I’ll test again on a fresh install today.

    Like I mentioned though, everything works perfectly in 2.9.0 (sorting works as expected, no php warning) –?something changed in more recent versions.

    Many thanks

    Thread Starter tictok

    (@tictok)

    Hi there – thanks for the bug fix!
    Unfortunately there are still issues ??

    The Warning: count(): Parameter must be an array or an object warnings are now all gone, so that’s good.

    However the Warning: Illegal string offset 'terms' in /plugins/reorder-post-within-categories/public/class-reorder-post-within-categories-public.php on line 130 warning remains and the sorting doesn’t work. (I can sort in the back end, but changes don’t display on the front end, and the PHP warnings are visible).

    I’ve tried with nothing other than the default 2021 theme, WooCommerce and your plugin. Nothing else installed or active, just the two plugins.

    Back to 2.9.0 for me. Just thought I’d let you know!
    Thanks

    Screenshots:
    https://snipboard.io/3HwFBN.jpg
    https://snipboard.io/sjTaQX.jpg

    • This reply was modified 3 years, 9 months ago by tictok.
    • This reply was modified 3 years, 9 months ago by tictok.
Viewing 15 replies - 1 through 15 (of 106 total)