• Resolved leocertuche

    (@leocertuche)


    Hello experts! I’ll first provide some CONTEXT and then I’ll describe my ISSUE.

    CONTEXT:

    I’m currently building a woocommerce store for dropshipping several shopify stores. Each of shopify has its own particular taxonomy. I am successfully bringing information from the first shopify store such as title, variants, images, body_html, product_type, vendor and an attribute with “name”: “Size” and its variants such as “price” and “inventory_quantity”.

    In order to register the custom taxonomies in woocommerce, the following lines were added to the theme’s functions.php file:

    <?php
    function register_product_custom_taxonomies() {
    $attributes = [
    'store' => 'Store',
    'product_kind' => 'Product Kind',
    'size' => 'Size',
    'color' => 'Color',
    'vendor' => 'Vendor',
    'style' => 'Style',
    'axle_size' => 'Axle Size',
    'size_kids' => 'Size (Kids)',
    'pads_vendor' => 'Pads Vendor',
    'vol_wax' => 'Volume (Wax)',
    'vol_degrease' => 'Volume (Degrease)',
    'valve_color' => 'Valve Color',
    'vol_sealant' => 'Volume (Sealant)',
    'stem_diameter' => 'Stem Diameter',
    'socks_design' => 'Socks Design'
    ];

    foreach ($attributes as $slug => $label) {
    $taxonomy_slug = 'custom_' . $slug; // Prefix for uniqueness
    register_taxonomy(
    $taxonomy_slug,
    ['product'],
    [
    'labels' => [
    'name' => $label,
    'singular_name' => $label,
    ],
    'hierarchical' => false,
    'show_ui' => true,
    'public' => true,
    'show_in_menu' => true,
    'show_admin_column' => true,
    'show_in_rest' => true,
    'rewrite' => ['slug' => sanitize_title($label)],
    ]
    );
    }
    }
    add_action('init', 'register_product_custom_taxonomies');
    ?>

    The reason I decided to use custom taxonomies is because I want to use the plugin called “Filter Everything PRO” to created taxonomy-based filters in the Products Archive page.

    It seems like registering taxonomies alone is not enough so I also performed Attribute Registration in WooCommerce, the following lines were ran once in the theme’s functions.php file:

    <?php
    function register_custom_global_attributes_with_sql() {
    global $wpdb;

    $attributes = [
    'custom_store' => 'Store',
    'custom_product_kind' => 'Product Kind',
    'custom_size' => 'Size',
    'custom_color' => 'Color',
    'custom_vendor' => 'Vendor',
    'custom_style' => 'Style',
    'custom_axle_size' => 'Axle Size',
    'custom_size_kids' => 'Size (Kids)',
    'custom_pads_vendor' => 'Pads Vendor',
    'custom_vol_wax' => 'Volume (Wax)',
    'custom_vol_degrease' => 'Volume (Degrease)',
    'custom_valve_color' => 'Valve Color',
    'custom_vol_sealant' => 'Volume (Sealant)',
    'custom_stem_diameter' => 'Stem Diameter',
    'custom_socks_design' => 'Socks Design',
    ];

    foreach ($attributes as $slug => $name) {
    // Check if the attribute exists in the WooCommerce database
    $exists = $wpdb->get_var($wpdb->prepare(
    "SELECT attribute_id FROM {$wpdb->prefix}woocommerce_attribute_taxonomies WHERE attribute_name = %s",
    $slug
    ));

    if (!$exists) {
    // Insert attribute into the database via SQL query
    $wpdb->insert(
    "{$wpdb->prefix}woocommerce_attribute_taxonomies",
    [
    'attribute_name' => $slug,
    'attribute_label' => $name,
    'attribute_type' => 'select',
    'attribute_orderby'=> 'menu_order',
    'attribute_public' => 1,
    ]
    );
    }
    }

    // Refresh WooCommerce's cached attributes
    delete_transient('wc_attribute_taxonomies');
    }
    add_action('init', 'register_custom_global_attributes_with_sql');
    ?>

    ISSUE:

    When any of the programatically created products are seen in the Single Product page, variations are not being shown. If I omit the custom taxonomies from the theme’s functions.php, variations on the single product page work just fine.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter leocertuche

    (@leocertuche)

    I forgot to add details about my environment. Here they are:

    <br>### WordPress Environment ###<br><br>WordPress address (URL): [Redacted]<br>Site address (URL): [Redacted]<br>WC Version: 9.4.2<br>Legacy REST API Package Version: The Legacy REST API plugin is not installed on this site.<br>Action Scheduler Version: ? 3.8.2<br>Log Directory Writable: ?<br>WP Version: 6.7.1<br>WP Multisite: –<br>WP Memory Limit: 2 GB<br>WP Debug Mode: ?<br>WP Cron: ?<br>Language: es_CO<br>External object cache: ?<br><br>### Server Environment ###<br><br>Server Info: LiteSpeed<br>PHP Version: 8.2.16<br>PHP Post Max Size: 2 GB<br>PHP Time Limit: 360<br>PHP Max Input Vars: 5000<br>cURL Version: 7.87.0<br>OpenSSL/1.1.1w<br><br>SUHOSIN Installed: –<br>MySQL Version: 10.11.10-MariaDB<br>Max Upload Size: 2 GB<br>Default Timezone is UTC: ?<br>fsockopen/cURL: ?<br>SoapClient: ?<br>DOMDocument: ?<br>GZip: ?<br>Multibyte String: ?<br>Remote Post: ?<br>Remote Get: ?<br><br>### Database ###<br><br>WC Database Version: 9.4.2<br>WC Database Prefix: wcc_<br>Total Database Size: 199.23MB<br>Database Data Size: 183.90MB<br>Database Index Size: 15.33MB<br>wcc_woocommerce_sessions: Data: 0.22MB + Index: 0.02MB + Engine InnoDB<br>wcc_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB<br>wcc_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_woocommerce_order_itemmeta: Data: 0.05MB + Index: 0.03MB + Engine InnoDB<br>wcc_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB<br>wcc_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_actionscheduler_actions: Data: 1.44MB + Index: 0.66MB + Engine InnoDB<br>wcc_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_actionscheduler_logs: Data: 1.50MB + Index: 0.31MB + Engine InnoDB<br>wcc_addonlibrary_addons: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_addonlibrary_categories: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_asnp_wepb_simple_bundle_items: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_atum_order_itemmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_atum_order_items: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_atum_product_data: Data: 0.06MB + Index: 0.05MB + Engine InnoDB<br>wcc_cjtoolbox_authors: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_cjtoolbox_backups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_cjtoolbox_blocks: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_cjtoolbox_block_files: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_cjtoolbox_block_pins: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_cjtoolbox_block_templates: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_cjtoolbox_forms: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_cjtoolbox_form_groups: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_cjtoolbox_form_group_parameters: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_cjtoolbox_form_group_xfields: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_cjtoolbox_packages: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_cjtoolbox_package_objects: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_cjtoolbox_parameters: Data: 0.02MB + Index: 0.05MB + Engine InnoDB<br>wcc_cjtoolbox_parameter_typedef: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_cjtoolbox_parameter_typeparams: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_cjtoolbox_templates: Data: 0.06MB + Index: 0.11MB + Engine InnoDB<br>wcc_cjtoolbox_template_revisions: Data: 0.09MB + Index: 0.02MB + Engine InnoDB<br>wcc_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_comments: Data: 0.02MB + Index: 0.09MB + Engine InnoDB<br>wcc_ctf_feeds: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_ctf_feeds_posts: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_ctf_feed_caches: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_ctf_feed_locator: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_ctf_posts: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_e_events: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_e_notes: Data: 0.02MB + Index: 0.17MB + Engine InnoDB<br>wcc_e_notes_users_relations: Data: 0.02MB + Index: 0.05MB + Engine InnoDB<br>wcc_e_submissions: Data: 0.02MB + Index: 0.27MB + Engine InnoDB<br>wcc_e_submissions_actions_log: Data: 0.02MB + Index: 0.11MB + Engine InnoDB<br>wcc_e_submissions_values: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_gla_attribute_mapping_rules: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_gla_budget_recommendations: Data: 0.19MB + Index: 0.11MB + Engine InnoDB<br>wcc_gla_merchant_issues: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_gla_shipping_rates: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_gla_shipping_times: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_jetpack_sync_queue: Data: 0.02MB + Index: 0.06MB + Engine InnoDB<br>wcc_jet_post_types: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_jet_smart_filters_indexer: Data: 0.05MB + Index: 0.00MB + Engine InnoDB<br>wcc_jet_taxonomies: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_litespeed_avatar: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_litespeed_img_optming: Data: 0.02MB + Index: 0.05MB + Engine InnoDB<br>wcc_litespeed_url: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_litespeed_url_file: Data: 0.02MB + Index: 0.08MB + Engine InnoDB<br>wcc_nm_personalized: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_options: Data: 13.48MB + Index: 0.25MB + Engine InnoDB<br>wcc_pmpro_discount_codes: Data: 0.02MB + Index: 0.05MB + Engine InnoDB<br>wcc_pmpro_discount_codes_levels: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_pmpro_discount_codes_uses: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_pmpro_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_pmpro_memberships_categories: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_pmpro_memberships_pages: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_pmpro_memberships_users: Data: 0.02MB + Index: 0.09MB + Engine InnoDB<br>wcc_pmpro_membership_levelmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_pmpro_membership_levels: Data: 0.02MB + Index: 0.05MB + Engine InnoDB<br>wcc_pmpro_membership_levels_groups: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_pmpro_membership_ordermeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_pmpro_membership_orders: Data: 0.02MB + Index: 0.20MB + Engine InnoDB<br>wcc_pmpro_subscriptionmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_pmpro_subscriptions: Data: 0.02MB + Index: 0.05MB + Engine InnoDB<br>wcc_postmeta: Data: 52.38MB + Index: 6.52MB + Engine InnoDB<br>wcc_posts: Data: 80.52MB + Index: 1.28MB + Engine InnoDB<br>wcc_s2w_error_product_images: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_sbi_feeds: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_sbi_feed_caches: Data: 0.14MB + Index: 0.02MB + Engine InnoDB<br>wcc_sbi_instagram_feeds_posts: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_sbi_instagram_feed_locator: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_sbi_instagram_posts: Data: 0.11MB + Index: 0.00MB + Engine InnoDB<br>wcc_sbi_sources: Data: 0.09MB + Index: 0.03MB + Engine InnoDB<br>wcc_snippets: Data: 0.06MB + Index: 0.03MB + Engine InnoDB<br>wcc_termmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_terms: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_term_relationships: Data: 0.06MB + Index: 0.05MB + Engine InnoDB<br>wcc_term_taxonomy: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_trp_dictionary_es_co_en_us: Data: 0.06MB + Index: 0.09MB + Engine InnoDB<br>wcc_trp_gettext_en_us: Data: 0.28MB + Index: 0.27MB + Engine InnoDB<br>wcc_trp_gettext_es_co: Data: 1.52MB + Index: 0.66MB + Engine InnoDB<br>wcc_trp_gettext_original_meta: Data: 0.02MB + Index: 0.05MB + Engine InnoDB<br>wcc_trp_gettext_original_strings: Data: 1.52MB + Index: 0.30MB + Engine InnoDB<br>wcc_trp_original_meta: Data: 0.05MB + Index: 0.05MB + Engine InnoDB<br>wcc_trp_original_strings: Data: 0.05MB + Index: 0.05MB + Engine InnoDB<br>wcc_uacf7_form: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_usermeta: Data: 0.14MB + Index: 0.03MB + Engine InnoDB<br>wcc_users: Data: 0.02MB + Index: 0.05MB + Engine InnoDB<br>wcc_wcpdf_invoice_number: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_wc_admin_notes: Data: 0.05MB + Index: 0.00MB + Engine InnoDB<br>wcc_wc_admin_note_actions: Data: 0.05MB + Index: 0.02MB + Engine InnoDB<br>wcc_wc_category_lookup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_wc_customer_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_wc_orders: Data: 0.02MB + Index: 0.11MB + Engine InnoDB<br>wcc_wc_orders_meta: Data: 0.06MB + Index: 0.11MB + Engine InnoDB<br>wcc_wc_order_addresses: Data: 0.02MB + Index: 0.06MB + Engine InnoDB<br>wcc_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_wc_order_operational_data: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_wc_order_product_lookup: Data: 0.02MB + Index: 0.06MB + Engine InnoDB<br>wcc_wc_order_stats: Data: 0.02MB + Index: 0.05MB + Engine InnoDB<br>wcc_wc_order_tax_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_wc_product_attributes_lookup: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_wc_product_download_directories: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_wc_product_meta_lookup: Data: 0.08MB + Index: 0.11MB + Engine InnoDB<br>wcc_wc_rate_limits: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_wc_reserved_stock: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_wfauditevents: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_wfblockediplog: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_wfblocks7: Data: 0.02MB + Index: 0.05MB + Engine InnoDB<br>wcc_wfconfig: Data: 2.52MB + Index: 0.00MB + Engine InnoDB<br>wcc_wfcrawlers: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_wffilechanges: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_wffilemods: Data: 16.55MB + Index: 0.00MB + Engine InnoDB<br>wcc_wfhits: Data: 0.09MB + Index: 0.05MB + Engine InnoDB<br>wcc_wfhoover: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_wfissues: Data: 0.02MB + Index: 0.06MB + Engine InnoDB<br>wcc_wfknownfilelist: Data: 7.52MB + Index: 0.00MB + Engine InnoDB<br>wcc_wflivetraffichuman: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_wflocs: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_wflogins: Data: 0.05MB + Index: 0.03MB + Engine InnoDB<br>wcc_wfls_2fa_secrets: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_wfls_role_counts: Data: 0.00MB + Index: 0.00MB + Engine MEMORY<br>wcc_wfls_settings: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_wfnotifications: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_wfpendingissues: Data: 0.02MB + Index: 0.06MB + Engine InnoDB<br>wcc_wfreversecache: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_wfsecurityevents: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_wfsnipcache: Data: 0.02MB + Index: 0.05MB + Engine InnoDB<br>wcc_wfstatus: Data: 0.19MB + Index: 0.13MB + Engine InnoDB<br>wcc_wftrafficrates: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_wfwaffailures: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_wpfm_backup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_wpforms_logs: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_wpforms_payments: Data: 0.02MB + Index: 0.14MB + Engine InnoDB<br>wcc_wpforms_payment_meta: Data: 0.02MB + Index: 0.05MB + Engine InnoDB<br>wcc_wpforms_tasks_meta: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_wpf_filters: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_wpf_meta_keys: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_wpf_meta_values: Data: 0.02MB + Index: 0.03MB + Engine InnoDB<br>wcc_wpf_meta_values_bk: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_wtbp_favorites: Data: 0.02MB + Index: 0.02MB + Engine InnoDB<br>wcc_wtbp_tables: Data: 0.02MB + Index: 0.00MB + Engine InnoDB<br>wcc_yith_wcan_cache: Data: 0.02MB + Index: 0.06MB + Engine InnoDB<br><br>### Post Type Counts ###<br><br>attachment: 189<br>bc_x1379_op_type: 1<br>capitulos: 6<br>custom_css: 1<br>custom-css-js: 1<br>customize_changeset: 2<br>elementor_library: 35<br>elementor_snippet: 1<br>estudiantes: 3<br>filter-set: 1<br>flamingo_contact: 5<br>flamingo_inbound: 1<br>fsb_subscription: 3<br>fundadores: 7<br>jet-engine: 5<br>jet-smart-filters: 9<br>jet-woo-builder: 3<br>language_switcher: 4<br>mienbros: 10<br>nav_menu_item: 16<br>oembed_cache: 1<br>page: 24<br>post: 2<br>product: 48<br>product_variation: 399<br>revision: 825<br>shop_order: 26<br>trails: 22<br>voluntariados: 4<br>wc_product_table: 1<br>wooaio_buy_link: 3<br>wooaio_checkout: 1<br>wp_font_face: 33<br>wp_font_family: 12<br>wp_navigation: 1<br>wpcf7_contact_form: 1<br>wpcode: 2<br>wpforms: 1<br>yay-currency-manage: 3<br>yith_wcan_preset: 1<br><br>### Security ###<br><br>Secure connection (HTTPS): ?<br>Hide errors from visitors: ?<br><br>### Active Plugins (37) ###<br><br>Open Currency Converter: by Joe Hawes – 1.4.9<br>Automatic Translate Addon For Loco Translate: by Cool Plugins – 2.4.5<br>BC Woo Custom Thank You Pages: by WooCommerce & WordPress Tutorials – 1.4.19<br>Bold pagos en linea: by Bold – 3.0.6<br>Child Theme Configurator: by Lilaea Media – 2.6.6<br>CMP - Coming Soon & Maintenance Plugin: by NiteoThemes – 4.1.13<br>Code Snippets: by Code Snippets Pro – 3.6.5.1<br>Contact Form 7: by Takayuki Miyoshi – 6.0<br>CSS & JavaScript Toolbox: by Wipeout Media – 12.0.1<br>Custom Twitter Feeds: by Smash Balloon – 2.2.5<br>Elementor Pro: by Elementor.com – 3.25.4<br>Elementor: by Elementor.com – 3.25.10<br>EmbedPress: by WPDeveloper – 4.1.4<br>Filter Everything PRO: by Andrii Stepasiuk – 1.8.8<br>Flamingo: by Takayuki Miyoshi – 2.5<br>Google for WooCommerce: by WooCommerce – 2.9.0<br>Site Kit by Google: by Google – 1.140.0<br>Smash Balloon Instagram Feed: by Smash Balloon – 6.6.1<br>Jeg Elementor Kit: by Jegtheme – 2.6.10<br>JetEngine: by Crocoblock – 3.5.3<br>JetSmartFilters: by Crocoblock – 3.5.3<br>JetFormBuilder: by Crocoblock – 3.4.4<br>LiteSpeed Cache: by LiteSpeed Technologies – 6.5.2<br>Loco Translate: by Tim Whitlock – 2.6.14<br>Widgets for Social Photo Feed: by Trustindex.io  – 1.4.8<br>String Locator: by InstaWP – 2.6.6<br>Temporary Login: by Elementor.com – 1.3.0<br>Ultimate Addons for Contact Form 7: by Themefic – 3.4.14<br>Donation Platform for WooCommerce: Fundraising & Donation Management: by Jonas H?benreich – 1.3.3<br>Advanced Order Export For WooCommerce: by AlgolPlus – 3.5.6<br>PayU Payment Gateway for WooCommerce: by PayU SA – 2.6.1<br>Variation Swatches for WooCommerce: by Emran Ahmed – 2.1.2<br>Google Analytics for WooCommerce: by WooCommerce – 2.1.8<br>PDF Invoices & Packing Slips for WooCommerce: by WP Overnight – 3.9.0<br>WooCommerce: by Automattic – 9.4.2<br>Wordfence Security: by Wordfence – 8.0.1<br>WP File Manager: by mndpsingh287 – 8.0<br><br>### Inactive Plugins (5) ###<br><br>Akismet Anti-spam: Spam Protection: by Automattic - Anti-spam Team – 5.3.5<br>Hello Dolly: by Matt Mullenweg – 1.7.2<br>QCode - Departamentos y Ciudades de Colombia para Woocommerce: by QCode – 1.1.19<br>Query Monitor: by John Blackbourn – 3.16.4<br>WP-Sweep: by Lester 'GaMerZ' Chan – 1.1.8<br><br>### Dropin Plugins () ###<br><br>object-cache.php: LiteSpeed Cache - Object Cache (Drop-in)<br><br>### Must Use Plugins (2) ###<br><br>Disable Auto Updates: by  –<br>Elementor Safe Mode: by Elementor.com – 1.0.0<br><br>### Settings ###<br><br>Legacy API Enabled: –<br>Force SSL: –<br>Currency: COP ($)<br>Currency Position: left_space<br>Thousand Separator: .<br>Decimal Separator: ,<br>Number of Decimals: 0<br>Taxonomies: Product Types: accesorios (accesorios)<br>external (external)<br>grouped (grouped)<br>performance (performance)<br>simple (simple)<br>street wear (street-wear)<br>variable (variable)<br><br>Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog)<br>exclude-from-search (exclude-from-search)<br>featured (featured)<br>outofstock (outofstock)<br>rated-1 (rated-1)<br>rated-2 (rated-2)<br>rated-3 (rated-3)<br>rated-4 (rated-4)<br>rated-5 (rated-5)<br><br>Connected to WooCommerce.com: –<br>Enforce Approved Product Download Directories: ?<br>HPOS feature enabled: ?<br>Order datastore: Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore<br>HPOS data sync enabled: ?<br><br>### Logging ###<br><br>Enabled: ?<br>Handler: Automattic\WooCommerce\Internal\Admin\Logging\LogHandlerFileV2<br>Retention period: 30 days<br>Level threshold: –<br>Log directory size: 154 KB<br><br>### WC Pages ###<br><br>Shop base: #6 - /shop/<br>Cart: #1952 - /cart/ -  Contains the woocommerce/cart block<br>Checkout: ? Page does not contain the [woocommerce_checkout] shortcode or the woocommerce/checkout block.<br>My account: #9 - /my-account/<br>Terms and conditions: ? Page ID is set<br>but the page does not exist<br><br><br>### Theme ###<br><br>Name: Trochas Bicibles<br>Version: 4.6.0.1726506019<br>Author URL: https://woocommerce.com/<br>Child Theme: ?<br>Parent Theme Name: Storefront<br>Parent Theme Version: 4.6.0<br>Parent Theme Author URL: https://woocommerce.com/<br>WooCommerce Support: ?<br><br>### Templates ###<br><br>Overrides: –<br><br>### Admin ###<br><br>Enabled Features: activity-panels<br>analytics<br>product-block-editor<br>coupons<br>core-profiler<br>customize-store<br>customer-effort-score-tracks<br>import-products-task<br>experimental-fashion-sample-products<br>shipping-smart-defaults<br>shipping-setting-tour<br>homescreen<br>marketing<br>mobile-app-banner<br>navigation<br>onboarding<br>onboarding-tasks<br>pattern-toolkit-full-composability<br>product-custom-fields<br>remote-inbox-notifications<br>remote-free-extensions<br>payment-gateway-suggestions<br>printful<br>shipping-label-banner<br>subscriptions<br>store-alerts<br>transient-notices<br>woo-mobile-welcome<br>wc-pay-promotion<br>wc-pay-welcome-page<br>launch-your-store<br><br>Disabled Features: product-data-views<br>experimental-blocks<br>minified-js<br>product-pre-publish-modal<br>settings<br>async-product-editor-category-field<br>product-editor-template-system<br>blueprint<br>reactify-classic-payments-settings<br>use-wp-horizon<br><br>Daily Cron: ? Next scheduled: 2024-11-28 00:57:12 -05:00<br>Options: ?<br>Notes: 56<br>Onboarding: completed<br><br>### Action Scheduler ###<br><br>Complete: 634<br>Oldest: 2024-10-27 12:19:05 -0500<br>Newest: 2024-11-27 11:18:11 -0500<br><br>Failed: 1,201<br>Oldest: 2024-08-19 11:37:26 -0500<br>Newest: 2024-11-27 11:18:11 -0500<br><br>Pending: 7<br>Oldest: 2024-11-27 12:18:11 -0500<br>Newest: 2024-12-08 20:21:19 -0500<br><br><br>### Status report information ###<br><br>Generated at: 2024-11-27 11:45:57 -05:00<br>
    • This reply was modified 3 months, 2 weeks ago by leocertuche.
    Plugin Support shahzeen(woo-hc)

    (@shahzeenfarooq)

    Hi there!

    I understand your concern about variations not appearing on the single product page when using custom taxonomy code. Please note that we only provide support for WooCommerce core features, and assistance with customizations is outside our scope.

    Since the variations appear correctly after removing the custom code, it seems there are adjustments needed in your code to resolve this issue.

    If you need further assistance with customizations, we recommend reaching out to a developer or a WooCommerce customization expert. I can recommend?WooExperts?and?Codeable.io?as options for getting professional help. Alternatively, you can also ask your development questions in the??WooCommerce Community Slack?as custom code falls outside our usual?scope of support.

    Thank you

    Thread Starter leocertuche

    (@leocertuche)

    After a long conversation with this GPT https://chatgpt.com/g/g-BahnEMrJ0-wordpress-wizard here is the solution:

    First, register custom taxonomies with the tax_ preffix:

    function register_product_custom_taxonomies() {
    $attributes = [
    'custom_store' => 'Store',
    'custom_product_kind' => 'Product Kind',
    'custom_size' => 'Size',
    'custom_color' => 'Color',
    'custom_vendor' => 'Vendor',
    'custom_style' => 'Style',
    'custom_axle_size' => 'Axle Size',
    'custom_size_kids' => 'Size (Kids)',
    'custom_pads_vendor' => 'Pads Vendor',
    'custom_vol_wax' => 'Volume (Wax)',
    'custom_vol_degrease' => 'Volume (Degrease)',
    'custom_valve_color' => 'Valve Color',
    'custom_vol_sealant' => 'Volume (Sealant)',
    'custom_stem_diameter' => 'Stem Diameter',
    'custom_socks_design' => 'Socks Design',
    ];

    foreach ( $attributes as $slug => $label ) {
    $taxonomy_slug = 'tax_' . $slug; // Prefix for uniqueness

    register_taxonomy(
    $taxonomy_slug,
    ['product'], // Attach to WooCommerce products
    [
    'labels' => [
    'name' => $label,
    'singular_name' => $label,
    ],
    'hierarchical' => false,
    'show_ui' => true,
    'public' => true,
    'show_in_menu' => true,
    'show_admin_column' => true,
    'show_in_rest' => true,
    'rewrite' => ['slug' => sanitize_title( $label )],
    ]
    );
    }
    }
    add_action( 'init', 'register_product_custom_taxonomies' );

    Second, create a custom REST API Endpoint for replacing term IDs with term names for all products:

    add_action( 'rest_api_init', function () {
    register_rest_field( 'product', 'custom_taxonomy_terms', [
    'get_callback' => 'get_custom_taxonomy_terms',
    'schema' => null,
    ] );
    } );

    function get_custom_taxonomy_terms( $product ) {
    static $term_cache = []; // Cache terms to avoid redundant lookups
    $taxonomies = [
    'tax_custom_store' => 'Store',
    'tax_custom_product_kind' => 'Product Kind',
    'tax_custom_size' => 'Size',
    'tax_custom_color' => 'Color',
    'tax_custom_vendor' => 'Vendor',
    'tax_custom_style' => 'Style',
    'tax_custom_axle_size' => 'Axle Size',
    'tax_custom_size_kids' => 'Size (Kids)',
    'tax_custom_pads_vendor' => 'Pads Vendor',
    'tax_custom_vol_wax' => 'Volume (Wax)',
    'tax_custom_vol_degrease' => 'Volume (Degrease)',
    'tax_custom_valve_color' => 'Valve Color',
    'tax_custom_vol_sealant' => 'Volume (Sealant)',
    'tax_custom_stem_diameter' => 'Stem Diameter',
    'tax_custom_socks_design' => 'Socks Design',
    ];

    $product_id = $product['id'];
    $response = [];

    foreach ( $taxonomies as $taxonomy ) {
    if ( isset( $term_cache[ $taxonomy ][ $product_id ] ) ) {
    $response[ $taxonomy ] = $term_cache[ $taxonomy ][ $product_id ];
    continue;
    }

    $terms = get_the_terms( $product_id, $taxonomy );

    if ( ! is_wp_error( $terms ) && $terms ) {
    $names = array_map( function ( $term ) {
    return $term->name;
    }, $terms );

    $term_cache[ $taxonomy ][ $product_id ] = $names;
    $response[ $taxonomy ] = $names;
    }
    }

    return $response;
    }

    And third, Convert Taxonomy Terms into WooCommerce Global Terms:

    function convert_taxonomy_terms_to_wc_attributes() {
    global $wpdb;

    // Mapping of custom taxonomies to WooCommerce attribute slugs
    $taxonomies_to_attributes = [
    'tax_custom_size' => 'custom_size',
    'tax_custom_color' => 'custom_color',
    'tax_custom_vendor' => 'custom_vendor',
    'tax_custom_style' => 'custom_style',
    'tax_custom_axle_size' => 'custom_axle_size',
    'tax_custom_size_kids' => 'custom_size_kids',
    'tax_custom_pads_vendor' => 'custom_pads_vendor',
    'tax_custom_vol_wax' => 'custom_vol_wax',
    'tax_custom_vol_degrease' => 'custom_vol_degrease',
    'tax_custom_valve_color' => 'custom_valve_color',
    'tax_custom_vol_sealant' => 'custom_vol_sealant',
    'tax_custom_stem_diameter'=> 'custom_stem_diameter',
    ];

    foreach ( $taxonomies_to_attributes as $taxonomy => $wc_slug ) {
    // Get all terms from the taxonomy
    $terms = get_terms( [
    'taxonomy' => $taxonomy,
    'hide_empty' => false,
    ] );

    if ( is_wp_error( $terms ) || empty( $terms ) ) {
    continue; // Skip if there are no terms or an error occurred
    }

    foreach ( $terms as $term ) {
    // Check if the term already exists in the WooCommerce attribute terms
    $exists = $wpdb->get_var( $wpdb->prepare(
    "SELECT attribute_id FROM {$wpdb->prefix}woocommerce_attribute_taxonomies WHERE attribute_name = %s",
    $wc_slug
    ) );

    if ( ! $exists ) {
    // Create the WooCommerce attribute if it doesn't exist
    $wpdb->insert(
    "{$wpdb->prefix}woocommerce_attribute_taxonomies",
    [
    'attribute_name' => $wc_slug,
    'attribute_label' => ucwords( str_replace( '_', ' ', $wc_slug ) ),
    'attribute_type' => 'select',
    'attribute_orderby'=> 'menu_order',
    'attribute_public' => 1,
    ]
    );
    delete_transient( 'wc_attribute_taxonomies' ); // Refresh WooCommerce cache
    }

    // Add the term to the WooCommerce global attribute
    $term_exists = term_exists( $term->name, "pa_{$wc_slug}" );

    if ( ! $term_exists ) {
    wp_insert_term( $term->name, "pa_{$wc_slug}" );
    }
    }
    }
    }
    add_action( 'init', 'convert_taxonomy_terms_to_wc_attributes' );

    Now, even though the products were created programatically and each of their variations were not global but per-product, its attributes are now shown as global and variations are displayed in the single product page.

    • This reply was modified 3 months, 1 week ago by leocertuche.
    Plugin Support Zubair Zahid (woo-hc)

    (@doublezed2)

    Hello leocertuche,

    Thank you for your reply.

    I am glad to know that you have figured out a solution.
    I appreciate you for sharing the solution here.
    It will be helpful for other users who might be in a similar situation.

    Have a great day!

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.