Forum Replies Created

Viewing 10 replies - 31 through 40 (of 40 total)
  • Thread Starter Mohammad Javed

    (@digitljaved)

    Have a look at these images too @ryanr14

    SCREENSHOTS

    The first image shows how the attribute data is being stored in the database with the latest version of WooCommerce & WordPress.

    The second image shows how the attribute USE TO BE stored in the database.

    Let me know how we can sort this out. Thank you.

    Thread Starter Mohammad Javed

    (@digitljaved)

    @ryanr14

    Here are the functions for the filtering that is located in setup.php in the functions folder situated in the child theme;

    /* Add sorting by attributes */
    
    /**
     *  Defines the criteria for sorting with options defined in the method below
     */
    add_filter( 'woocommerce_get_catalog_ordering_args', 'custom_woocommerce_get_catalog_ordering_args' );
    function custom_woocommerce_get_catalog_ordering_args($args)
    {
        global $wp_query;
    
        if ($_GET['orderby']) {
            $orderby_value = $_GET['orderby'];
        } else {
    
            $term = get_queried_object();
            $children = get_terms($term->taxonomy, array(
                'parent' => $term->term_id,
                'hide_empty' => false
            ));
            if(!$children){
                $orderby_value = apply_filters('woocommerce_default_catalog_orderby', get_option('woocommerce_default_catalog_orderby'));
            }else{
                $orderby_value = ''; // apply_filters('woocommerce_default_catalog_orderby', get_option('woocommerce_default_catalog_orderby'))
            }
        }
    
        $args = null;
        if(array_sum (check_capacity()) > 0){
            if ('pa_capacity_asc' == $orderby_value) {
                $args['orderby'] = 'meta_value_num';
                $args['order'] = 'asc';
                $args['meta_key'] = 'pa_capacity';
            } else if ('pa_capacity_desc' == $orderby_value) {
                $args['orderby'] = 'meta_value_num';
                $args['order'] = 'desc';
                $args['meta_key'] = 'pa_capacity';
            }
        }
    
        return $args;
    }
    
    function check_capacity(){
    
        global $wp_query;
    
        $out = [];
        $curr_cat_id = $wp_query->get_queried_object()->term_id;
        $args = array(
            'post_type' => 'product',
            'posts_per_page' => -1,
            'tax_query' => array(
                'relation' => 'AND',
                array(
                    'taxonomy' => 'product_cat',
                    'field' => 'term_id',
                    'terms' => $curr_cat_id
                )
            ),
        );
        $loop = new WP_Query($args);
        if ($loop->have_posts()): while ($loop->have_posts()): $loop->the_post();
    
            global $product;
            $koostis = array_shift(wc_get_product_terms(get_the_ID(), 'pa_capacity', array('fields' => 'names')));
            $out[get_the_ID()] = $koostis;
    
        endwhile; endif;
        wp_reset_postdata();
    
        return($out);
    
    }
    add_filter( 'woocommerce_default_catalog_orderby_options', 'custom_woocommerce_catalog_orderby' );
    
    /**
     *  Adds the sorting options to dropdown list .. The logic/criteria is in the method above
     */
    add_filter( 'woocommerce_catalog_orderby', 'custom_woocommerce_catalog_orderby' );
    function custom_woocommerce_catalog_orderby( $sortby ) {
        $sortby['pa_capacity_asc'] = 'Sort by Capacity (Asc)';
        $sortby['pa_capacity_desc'] = 'Sort by Capacity (Desc)';
    
        return $sortby;
    }
    
    /**
     *  Save custom attributes as post's meta data as well so that we can use in sorting and searching
     */
    add_action( 'save_post', 'save_woocommerce_attr_to_meta' );
    function save_woocommerce_attr_to_meta( $post_id ) {
        $post_type = get_post_type($post_id);
        // If this isn't a 'product' post, don't update it.
        if ($post_type != 'product')
            return;
    
        // If attribute name and value exist
        if (!empty($_POST['attribute_names']) && !empty($_POST['attribute_values'])) {
            $attribute_names = $_POST['attribute_names'];
            $attribute_values = $_POST['attribute_values'];
    
            // Add post meta data for each attribute
            foreach( $attribute_names as $index => $attribute_name ) {
                update_post_meta( $post_id, $attribute_name, $attribute_values[$index] );
            }
        }
    }
    Thread Starter Mohammad Javed

    (@digitljaved)

    Hi @ryanr14

    We’ve noticed that the code base has changed and the way the product attribute data is being saved into the database.

    Due to this code change, the filtering has stopped working, you’ll notice that it’s working on other categories, the reason for this is because the product has not been saved so the way it stored the data in the database has not updated. Once you save the product without making any changes it stores the data different to the state that it was currently in. There has been an update somewhere that has made the codebase change and the way data is being stored in the database. If you need me to set up a staging environment of the website, I can do this for you so you can debug this?

    It’s changed the filters from a meta value to a term, when looking in the database it’s serializing the data. Instead of storing the attribute value against a meta_key it now stores a serialised reference to a term

    Does that make any sense to you?

    I look forward to hearing from you.

    Thank you,
    Javed

    Thread Starter Mohammad Javed

    (@digitljaved)

    Hi @ryanr14

    Do we have any updates on this?

    Thanks,
    Javed

    Thread Starter Mohammad Javed

    (@digitljaved)

    Hi @ryanr14

    The filtering has been added in through the functions file. We’ve not developed the website, we’ve just inherited it so don’t know the ins and outs of the site completely.

    Here is the requested information.

    
    ### WordPress Environment ###
    
    WordPress address (URL): https://www.tuffa.co.uk
    Site address (URL): https://www.tuffa.co.uk
    WC Version: 3.6.4
    Log Directory Writable: ?
    WP Version: 5.2.2
    WP Multisite: –
    WP Memory Limit: 256 MB
    WP Debug Mode: –
    WP Cron: ?
    Language: en_GB
    External object cache: –
    
    ### Server Environment ###
    
    Server Info: Apache/2.4.10 (Debian)
    PHP Version: 7.2.14-1+0~20190113100657.14+jessie~1.gbpd83c69
    PHP Post Max Size: 10 MB
    PHP Time Limit: 60
    PHP Max Input Vars: 2500
    cURL Version: 7.38.0
    OpenSSL/1.0.1t
    
    SUHOSIN Installed: –
    MySQL Version: ? 5.5.62-0+deb8u1 - We recommend a minimum MySQL version of 5.6. See: WordPress requirements
    Max Upload Size: 10 MB
    Default Timezone is UTC: ?
    fsockopen/cURL: ?
    SoapClient: ?
    DOMDocument: ?
    GZip: ?
    Multibyte String: ?
    Remote Post: ?
    Remote Get: ?
    
    ### Database ###
    
    WC Database Version: 3.6.4
    WC Database Prefix: wp_
    MaxMind GeoIP Database: ?
    Total Database Size: 44.52MB
    Database Data Size: 35.87MB
    Database Index Size: 8.65MB
    wp_woocommerce_sessions: Data: 0.01MB + Index: 0.00MB
    wp_woocommerce_api_keys: Data: 0.00MB + Index: 0.00MB
    wp_woocommerce_attribute_taxonomies: Data: 0.00MB + Index: 0.00MB
    wp_woocommerce_downloadable_product_permissions: Data: 0.00MB + Index: 0.00MB
    wp_woocommerce_order_items: Data: 0.00MB + Index: 0.00MB
    wp_woocommerce_order_itemmeta: Data: 0.00MB + Index: 0.00MB
    wp_woocommerce_tax_rates: Data: 0.00MB + Index: 0.01MB
    wp_woocommerce_tax_rate_locations: Data: 0.00MB + Index: 0.00MB
    wp_woocommerce_shipping_zones: Data: 0.00MB + Index: 0.00MB
    wp_woocommerce_shipping_zone_locations: Data: 0.00MB + Index: 0.00MB
    wp_woocommerce_shipping_zone_methods: Data: 0.00MB + Index: 0.00MB
    wp_woocommerce_payment_tokens: Data: 0.00MB + Index: 0.00MB
    wp_woocommerce_payment_tokenmeta: Data: 0.00MB + Index: 0.00MB
    wp_woocommerce_log: Data: 0.00MB + Index: 0.00MB
    wp_commentmeta: Data: 0.02MB + Index: 0.03MB
    wp_comments: Data: 0.08MB + Index: 0.09MB
    wp_links: Data: 0.02MB + Index: 0.02MB
    wp_litespeed_optimizer: Data: 0.00MB + Index: 0.00MB
    wp_nf3_actions: Data: 0.02MB + Index: 0.00MB
    wp_nf3_action_meta: Data: 0.05MB + Index: 0.00MB
    wp_nf3_chunks: Data: 0.02MB + Index: 0.00MB
    wp_nf3_fields: Data: 0.02MB + Index: 0.00MB
    wp_nf3_field_meta: Data: 0.09MB + Index: 0.00MB
    wp_nf3_forms: Data: 0.02MB + Index: 0.00MB
    wp_nf3_form_meta: Data: 0.02MB + Index: 0.00MB
    wp_nf3_objects: Data: 0.02MB + Index: 0.00MB
    wp_nf3_object_meta: Data: 0.02MB + Index: 0.00MB
    wp_nf3_relationships: Data: 0.02MB + Index: 0.00MB
    wp_nf3_upgrades: Data: 0.02MB + Index: 0.00MB
    wp_options: Data: 4.22MB + Index: 0.08MB
    wp_postmeta: Data: 16.52MB + Index: 5.97MB
    wp_posts: Data: 12.52MB + Index: 1.06MB
    wp_redirection_404: Data: 0.69MB + Index: 0.36MB
    wp_redirection_groups: Data: 0.00MB + Index: 0.00MB
    wp_redirection_items: Data: 0.01MB + Index: 0.01MB
    wp_redirection_logs: Data: 0.03MB + Index: 0.02MB
    wp_smush_dir_images: Data: 0.00MB + Index: 0.00MB
    wp_termmeta: Data: 0.08MB + Index: 0.03MB
    wp_terms: Data: 0.05MB + Index: 0.03MB
    wp_termsmeta: Data: 0.00MB + Index: 0.01MB
    wp_term_relationships: Data: 0.16MB + Index: 0.14MB
    wp_term_taxonomy: Data: 0.16MB + Index: 0.03MB
    wp_usermeta: Data: 0.11MB + Index: 0.03MB
    wp_users: Data: 0.02MB + Index: 0.05MB
    wp_wc_admin_notes: Data: 0.02MB + Index: 0.00MB
    wp_wc_admin_note_actions: Data: 0.02MB + Index: 0.02MB
    wp_wc_customer_lookup: Data: 0.02MB + Index: 0.03MB
    wp_wc_download_log: Data: 0.02MB + Index: 0.03MB
    wp_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB
    wp_wc_order_product_lookup: Data: 0.02MB + Index: 0.06MB
    wp_wc_order_stats: Data: 0.02MB + Index: 0.05MB
    wp_wc_order_tax_lookup: Data: 0.02MB + Index: 0.03MB
    wp_wc_product_meta_lookup: Data: 0.05MB + Index: 0.09MB
    wp_wc_webhooks: Data: 0.02MB + Index: 0.02MB
    wp_wfbadleechers: Data: 0.02MB + Index: 0.00MB
    wp_wfblockediplog: Data: 0.02MB + Index: 0.00MB
    wp_wfblocks: Data: 0.02MB + Index: 0.02MB
    wp_wfblocksadv: Data: 0.02MB + Index: 0.00MB
    wp_wfconfig: Data: 0.02MB + Index: 0.00MB
    wp_wfcrawlers: Data: 0.02MB + Index: 0.00MB
    wp_wffilemods: Data: 0.02MB + Index: 0.00MB
    wp_wfhits: Data: 0.02MB + Index: 0.05MB
    wp_wfhoover: Data: 0.02MB + Index: 0.02MB
    wp_wfissues: Data: 0.02MB + Index: 0.00MB
    wp_wfknownfilelist: Data: 0.02MB + Index: 0.00MB
    wp_wfleechers: Data: 0.02MB + Index: 0.00MB
    wp_wflockedout: Data: 0.02MB + Index: 0.00MB
    wp_wflocs: Data: 0.02MB + Index: 0.00MB
    wp_wflogins: Data: 0.02MB + Index: 0.03MB
    wp_wfnet404s: Data: 0.02MB + Index: 0.02MB
    wp_wfnotifications: Data: 0.02MB + Index: 0.00MB
    wp_wfpendingissues: Data: 0.02MB + Index: 0.00MB
    wp_wfreversecache: Data: 0.02MB + Index: 0.00MB
    wp_wfscanners: Data: 0.02MB + Index: 0.00MB
    wp_wfsnipcache: Data: 0.02MB + Index: 0.05MB
    wp_wfstatus: Data: 0.02MB + Index: 0.03MB
    wp_wfthrottlelog: Data: 0.02MB + Index: 0.02MB
    wp_wfvulnscanners: Data: 0.02MB + Index: 0.00MB
    wp_yoast_seo_links: Data: 0.09MB + Index: 0.03MB
    wp_yoast_seo_meta: Data: 0.05MB + Index: 0.05MB
    
    ### Post Type Counts ###
    
    acf-field: 59
    acf-field-group: 4
    attachment: 1845
    custom_css: 1
    faq: 41
    mc4wp-form: 1
    nav_menu_item: 75
    nf_sub: 615
    oembed_cache: 1
    page: 34
    post: 368
    product: 280
    product_variation: 6
    revision: 1865
    scheduled-action: 104
    
    ### Security ###
    
    Secure connection (HTTPS): ?
    Hide errors from visitors: ?
    
    ### Active Plugins (21) ###
    
    Advanced Custom Fields PRO: by Elliot Condon – 5.8.1
    Advanced Custom Fields: by Elliot Condon – 5.8.1
    Categories Images: by Muhammad Said El Zahlan – 2.5.4
    Disable Gutenberg: by Jeff Starr – 1.8.1
    Google Tag Manager for WordPress: by Thomas Geiger – 1.9.2 – Not tested with the active version of WooCommerce
    Filename-based asset cache busting: by Ben Lumley – 1.3
    JivoChat: by JivoChat – 1.3.3
    Mailchimp for WordPress: by ibericode – 4.5.2
    Ninja Forms: by The WP Ninjas – 3.4.16
    Redirection: by John Godley – 4.3.1
    Regenerate Thumbnails: by Alex Mills (Viper007Bond) – 3.1.1
    Simple Custom Post Order: by Colorlib – 2.4.4
    SVG Support: by Benbodhi – 2.3.15
    TAO Schedule Update: by TAO Digital – 1.15
    Tweetlab: by MaGeek Lab – 2.0.2
    Premmerce Permalink Manager for WooCommerce: by premmerce – 2.1.9
    WooCommerce: by Automattic – 3.6.4 – 3.6.5 is available
    WordPress Importer: by wordpressdotorg – 0.6.4
    Yoast SEO: by Team Yoast – 11.4 – Not tested with the active version of WooCommerce
    WP Media Category Management: by DeBAAT  – 1.9.4
    YITH WooCommerce Catalog Mode: by YITH – 1.6.9
    
    ### Inactive Plugins (8) ###
    
    Akismet Anti-Spam: by Automattic – 4.1.2
    Autoptimize: by Frank Goossens (futtta) – 2.5.1
    Category and Taxonomy Meta Fields: by Aftab Husain – 1.0.0
    Lazy Loader: by Florian Brinkmann
    MarcDK – 4.1.0
    
    Smush: by WPMU DEV – 3.2.1
    W3 Total Cache: by Frederick Townes – 0.9.7.5
    WooCommerce Admin: by WooCommerce – 0.14.0
    Wordfence Security: by Wordfence – 7.3.4
    
    ### Settings ###
    
    API Enabled: ?
    Force SSL: –
    Currency: GBP (£)
    Currency Position: left
    Thousand Separator: ,
    Decimal Separator: .
    Number of Decimals: 2
    Taxonomies: Product Types: external (external)
    grouped (grouped)
    simple (simple)
    variable (variable)
    
    Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)
    exclude-from-search (exclude-from-search)
    featured (featured)
    outofstock (outofstock)
    rated-1 (rated-1)
    rated-2 (rated-2)
    rated-3 (rated-3)
    rated-4 (rated-4)
    rated-5 (rated-5)
    
    Connected to WooCommerce.com: –
    
    ### WC Pages ###
    
    Shop base: #4 - /shop/
    Basket: #5 - /cart/
    Checkout: #6 - /checkout/
    My account: #7 - /my-account/
    Terms and conditions: ? Page not set
    
    ### Theme ###
    
    Name: storefront-child
    Version: 2.2.4
    Author URL: https://woocommerce.com/
    Child Theme: ?
    Parent Theme Name: Storefront
    Parent Theme Version: 2.2.4 – 2.5.0 is available
    Parent Theme Author URL: https://woocommerce.com/
    WooCommerce Support: ?
    
    ### Templates ###
    
    Overrides: storefront-child/woocommerce/archive-product.php version 2.0.0 is out of date. The core version is 3.4.0
    storefront-child/woocommerce/global/breadcrumb.php
    storefront-child/woocommerce/loop/orderby.php version 2.2.0 is out of date. The core version is 3.6.0
    storefront-child/woocommerce/single-product/product-attributes.php version 3.1.0 is out of date. The core version is 3.6.0
    storefront-child/woocommerce/single-product/related.php
    storefront-child/woocommerce/single-product/short-description.php version 1.6.4 is out of date. The core version is 3.3.0
    storefront-child/woocommerce/single-product/tabs/tabs.php
    storefront-child/woocommerce/single-product/title.php
    storefront-child/woocommerce/single-product/up-sells.php
    
    Outdated Templates: ?
    					
    					
    						Learn how to update
    
    ### Action Scheduler ###
    
    Complete: 103
    Oldest: 2019-06-17 10:04:06 +0000
    Newest: 2019-06-26 11:29:54 +0000
    
    Pending: 0
    Oldest: –
    Newest: –
    
    Canceled: 1
    Oldest: 2019-06-26 12:29:54 +0000
    Newest: 2019-06-26 12:29:54 +0000
    
    In-progress: 0
    Oldest: –
    Newest: –
    
    Failed: 0
    Oldest: –
    Newest: –
    
    

    Let me know if there is anything else you need me to check or provide to you.

    Thanks,
    Javed

    Thread Starter Mohammad Javed

    (@digitljaved)

    Hi Ryan,

    I know the theme is quite outdated, it needs updating, I’ve tried this and there are loads of breaking changes.

    The dropdowns are accessible if you filter the products by capacity only it does not work, but if you go to another category the capacity filtering works perfectly.

    I’m baffled that this works on 3 other servers and the server it’s hosted on is where this filtering problem has appeared.

    I’m not sure what to even do, it might be that we need to update the theme to the latest version possible and see if the capacity filtering works on that category in question.

    Thank you,
    J

    Thread Starter Mohammad Javed

    (@digitljaved)

    Thanks, that worked. It looks like this is a recent change in the plugin as this was not happening when I’ve installed the plugin a few weeks ago.

    Thread Starter Mohammad Javed

    (@digitljaved)

    Thanks, Tom, that’s really helpful and will help me achieve what I am looking for.

    Thread Starter Mohammad Javed

    (@digitljaved)

    Any ideas of a plugin?

    I think I might have sorted this out in the end. But if there is a plugin you can recommend that would be great.

    Thread Starter Mohammad Javed

    (@digitljaved)

    So those settings are only available for those that have purchased the premium plugin?

Viewing 10 replies - 31 through 40 (of 40 total)