• frafor

    (@frafor)


    Hi there and many thanks for the great plugin!

    Today I noticed that even if “Item data” is set to “Display” in WPC Fly Cart options, product attributes did not appear within the woofc-item-data span.

    So I checked the wc_get_formatted_cart_item_data() function in woocommerce and it clearly states that:

    “Variation values are shown only if they are not found in the title as of 3.0.
    This is because variation titles display the attributes.”

    Reference: https://github.com/woocommerce/woocommerce/blob/dfc2f70f4610b8114df0627b87ad9035e2f0d51f/plugins/woocommerce/includes/wc-template-functions.php#L3775

    I guess the problem here might be that Fly Cart is using get_name() on WC_Product instead of WC_Product_Variation (as wc_get_formatted_cart_item_data seems to do) so the product name does not account for the variation-added attributes, but I am not entirely sure for this.

    To get product attributes show up under the cart name as a quick fix, I have just replicated the code in wc_get_formatted_cart_item_data in another function that filters woocommerce_get_item_data, omitting these lines:

    // Check the nicename against the title.
    if ( ” === $value || wc_is_attribute_in_product_name( $value, $cart_item[‘data’]->get_name() ) ) {
    continue;
    }

    However this led to showing the product attributes twice on other plugins I use (such as “Change Quantity on Checkout for WooCommerce” which correctly shows variations names in the cart as {product_name} – {variation_value}) so I will move to a woofc-specific action/filter instead.

    Just wanted to let you know.

  • The topic ‘get_cart_area() does not show product attributes as item data’ is closed to new replies.