• Resolved ilanaguttman

    (@ilanaguttman)


    I’ve set a few different attributes such as “color” and then selected the appropriate color for each attribute from the color picker. But then on the individual product when I go to add them, the plugin turns what I’ve selected, such as “black”, “brown”, etc., into some new color and gives it just a number like “38”.
    It’s difficult to explain so I created a screencast: https://screencast.com/t/LypMiENTYCDG

Viewing 5 replies - 1 through 5 (of 5 total)
  • I got this problem too.

    I add the colors to the product…

    View post on imgur.com

    But then after I “Update” the product they turn into numbers!?

    View post on imgur.com

    Help please

    BEFORE + AFTER

    Hey @ilanaguttman,

    I figured it out myself:

    line 204 of variation-swatches-for-woocommerce/includes/class-admin.php

    inside that foreach loop replace
    $term->id with $term->slug

    ??

    Thread Starter ilanaguttman

    (@ilanaguttman)

    Hi @markendley,
    Thanks so much for checking this out. That worked perfectly!!!
    Much appreciated!!

    Thread Starter ilanaguttman

    (@ilanaguttman)

    So, I noticed that all of the extra attributes keep getting added back in. If I edit a product and select that the colors are: yellow gold, silver, rose gold, then after updating the product, it adds in all of the other possible colors too as attributes that don’t get added to the possible variations. This is a problem in that all of these excess attributes show up under the product’s “additional information” tab.

    massafiri

    (@massafiri)

    Thanks @markendley

    I also experienced this bug, including the same issue @ilanaguttman with all the terms showing up.

    The reason why you’re getting all the Attributes is because you only need to changed the first $term->term_id to $term->slug.

    if ( $all_terms ) {
    foreach ( $all_terms as $term ) {
    echo '<option value="' . esc_attr( $term->slug ) . '" ' . selected( has_term( absint( $term->term_id ), $taxonomy_name, $thepostid ), true, false ) . '>' . esc_attr( apply_filters( 'woocommerce_product_attribute_term_name', $term->name, $term ) ) . '</option>';
    				}
    			}

    If you notice the second $term->term_id is wrapped in this code:
    selected( has_term( absint( $term->term_id )

    absint() is a number function, so putting a string in there returns the same result every time, and hence why all attributes showing up.

    Looks to be working now!

    • This reply was modified 7 years ago by massafiri.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Color Swatches Resetting’ is closed to new replies.