[Support request] How to increase variations in woocommerce products?

Home Forums Support How to increase variations in woocommerce products?

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #942091
    Jorge

    Hi.
    I do not have knowledge in informatics and codes
    but I need to increase the variations of my products to 500 but I can not find a code that works well
    they could help me with a code to increase the variations of my products
    Could you tell me where to write the code?

    I’m uploading the information a little bit later to pass it to elementor

    #942110
    Leo
    Staff
    Customer Support

    Hi there,

    Not sure if I fully understand.

    Can you guide me to the page in question?

    I don’t see any WooCommmerce products in the site you linked.

    Let me know 🙂

    #942194
    Jorge

    I have not published anything yet.
    because I need to increase the variations is
    say put 500 different prices to each product.
    I will expose my need:
    I sell Panama hats, I use 3 attributes for each model
    Size: 11 options
    Quality: 15 options
    Tape color: 3 options
    in a total of 495 options
    for this, I need 495 variations in each model
    because the attributes make prices vary
    default woocommerce have 50 variations
    but I’ve seen pages that work with more variations
    with 66 I could also upload my products, which would use categories.
    but what I want is to increase those variations

    I’m starting with the products but I’m using a child theme
    generatepress
    I know this can be increased by using codes
    but I do not know what works with the theme
    nor where do you put the code

    #942207
    Leo
    Staff
    Customer Support

    What code did you find?

    Should be the same code regardless which theme you are using as the function is all handled by WooCommerce plugin itself.

    I would assume it’s PHP so can be added using one of these methods:
    Adding PHP: https://docs.generatepress.com/article/adding-php/

    #942226
    Jorge

    use this code in function php
    <?php
    function ww_ajax_variation_threshold( $default, $product ) {
    return 50; // increase this number if needed
    }
    add_filter( ‘woocommerce_ajax_variation_threshold’, ‘ww_ajax_variation_threshold’, 10, 2 );
    ?>

    and this one too

    define (‘WC_MAX_LINKED_VARIATIONS’, 500);

      but in none, it was not complete.

    #942235
    Leo
    Staff
    Customer Support
    #942253
    Jorge

    under what line of code should I write it? that is the code of the blog that you sent me

    This is an image of the theme editor
    ?php

    /**
    * GeneratePress.
    *
    * Please do not make any edits to this file. All edits should be done in a child theme.
    *
    * @package GeneratePress
    */

    if ( ! defined( ‘ABSPATH’ ) ) {
    exit; // Exit if accessed directly.
    }

    // Set our theme version.
    define( ‘GENERATE_VERSION’, ‘2.3.2’ );

    if ( ! function_exists( ‘generate_setup’ ) ) {
    add_action( ‘after_setup_theme’, ‘generate_setup’ );
    /**
    * Sets up theme defaults and registers support for various WordPress features.
    *
    * @since 0.1
    */
    function generate_setup() {
    // Make theme available for translation.
    load_theme_textdomain( ‘generatepress’ );

    // Add theme support for various features.
    add_theme_support( ‘automatic-feed-links’ );
    add_theme_support( ‘post-thumbnails’ );
    add_theme_support( ‘post-formats’, array( ‘aside’, ‘image’, ‘video’, ‘quote’, ‘link’, ‘status’ ) );
    add_theme_support( ‘woocommerce’ );
    add_theme_support( ‘title-tag’ );
    add_theme_support( ‘html5’, array( ‘search-form’, ‘comment-form’, ‘comment-list’, ‘gallery’, ‘caption’ ) );
    add_theme_support( ‘customize-selective-refresh-widgets’ );
    add_theme_support( ‘align-wide’ );
    add_theme_support( ‘editor-color-palette’, array() );
    add_theme_support( ‘responsive-embeds’ );

    add_theme_support( ‘custom-logo’, array(
    ‘height’ => 70,
    ‘width’ => 350,
    ‘flex-height’ => true,
    ‘flex-width’ => true,
    ) );

    // Register primary menu.
    register_nav_menus( array(
    ‘primary’ => __( ‘Primary Menu’, ‘generatepress’ ),
    ) );

    /**
    * Set the content width to something large
    * We set a more accurate width in generate_smart_content_width()
    */
    global $content_width;
    if ( ! isset( $content_width ) ) {
    $content_width = 1200; /* pixels */
    }

    // This theme styles the visual editor to resemble the theme style.
    add_editor_style( ‘css/admin/editor-style.css’ );
    }
    }

    /**
    * Get all necessary theme files
    */
    require get_template_directory() . ‘/inc/theme-functions.php’;
    require get_template_directory() . ‘/inc/defaults.php’;
    require get_template_directory() . ‘/inc/class-css.php’;
    require get_template_directory() . ‘/inc/css-output.php’;
    require get_template_directory() . ‘/inc/general.php’;
    require get_template_directory() . ‘/inc/customizer.php’;
    require get_template_directory() . ‘/inc/markup.php’;
    require get_template_directory() . ‘/inc/typography.php’;
    require get_template_directory() . ‘/inc/plugin-compat.php’;
    require get_template_directory() . ‘/inc/block-editor.php’;
    require get_template_directory() . ‘/inc/migrate.php’;
    require get_template_directory() . ‘/inc/deprecated.php’;

    if ( is_admin() ) {
    require get_template_directory() . ‘/inc/meta-box.php’;
    require get_template_directory() . ‘/inc/dashboard.php’;
    }

    /**
    * Load our theme structure
    */
    require get_template_directory() . ‘/inc/structure/archives.php’;
    require get_template_directory() . ‘/inc/structure/comments.php’;
    require get_template_directory() . ‘/inc/structure/featured-images.php’;
    require get_template_directory() . ‘/inc/structure/footer.php’;
    require get_template_directory() . ‘/inc/structure/header.php’;
    require get_template_directory() . ‘/inc/structure/navigation.php’;
    require get_template_directory() . ‘/inc/structure/post-meta.php’;
    require get_template_directory() . ‘/inc/structure/sidebars.php’;

    #942258
    Leo
    Staff
    Customer Support

    Add this code:

    function custom_wc_ajax_variation_threshold( $qty, $product )
    {
        return 100;
    }
    add_filter( 'woocommerce_ajax_variation_threshold', 'custom_wc_ajax_variation_threshold', 10, 2 );

    Using one of these methods:
    https://docs.generatepress.com/article/adding-php/

    Don’t modify the theme’s core files. Code Snippets plugin is the easiest way.

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