• Resolved Sogwap

    (@sogwap)


    I found a bug, that if two products have the same fee name. Only first product fee is displayed and applies. Any other products with the same fee name is ignored.

    This is big problem as I will have hundreds of products and will be next to impossible to think of unique names for every product that will be easy to manage and make sense.

    One way around this would be to combine the SKU with the fee name? as this would make every product fee unique.
    Another way would be to allow accumulative product fees with same name so that if one product had quantity of one, and a second with quantity of three, it would display total of four product for that fee. Currently it will display one or three product fees depending on the order listed.

    https://www.ads-software.com/plugins/woocommerce-product-fees/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    Hi Sogwap,

    Yea, I have come across this issue as well. The problem is that there is no other parameter to invisibly identify them as separate fees: https://github.com/woothemes/woocommerce/blob/3e55364e3a1ecf0dc93bd796c51cd85093de5127/includes/class-wc-cart.php#L1909

    I could add in the SKU’s to be appended, but I have a feeling most would not like how that looks. The addition idea could work though. Let me look into this, and see what the best solution available is.

    In the meantime, you could manually add in the SKU’s to the fee name.

    Plugin Author Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    I’m gonna see if this is something that should be added to core actually. Issue created here: https://github.com/woothemes/woocommerce/issues/9193#issuecomment-142116874

    Thread Starter Sogwap

    (@sogwap)

    Since I have only one type of fee I made one change in file:
    /wp-content/plugins/woocommerce-product-fees/classes/class-woocommerce-product-fees.php

    From this:

    // Send multiplied fee data to add_product_fee()
    $this->add_product_fee( $new_product_fee, $product_fee_name );

    To this:

    // Send multiplied fee data to add_product_fee()
    // $this->add_product_fee( $new_product_fee, $product_fee_name );
    $this->add_product_fee( $new_product_fee, ‘Bottle Deposit Item #’ . $product_id );

    Obviously not ideal. But a simple quick fix in my situation.
    In essence it changes the $product_fee_name to fixed name and append the $product_id

    Plugin Author Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    Oh, there is a better way to achieve that though.

    If you want the fees to be named like this: https://cld.wthms.co/1fGEM/FlxOJhGY, then try the following snippet in your child theme’s functions.php file:

    add_filter( 'woocommerce_product_fees_filter_fee_data', 'wc_ninja_prefix_fees' );
    
    function wc_ninja_prefix_fees( $fee ) {
    
    	$fee['name'] = 'Bottle Deposit Item #' . $fee['product_id'];
    
    	return $fee;
    
    }

    It hooks into a filter in the plugin so you do not have to override the core files. We are hooking into this filter: https://github.com/WPprodigy/woocommerce-product-fees/blob/master/classes/class-woocommerce-product-fees.php#L143, and returning the fee with an altered name.

    In other news, I believe WooCommerce core will soon be able to just add the fees together when they are the same name.

    Plugin Author Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    It looks like WooCommerce core will not be adding this in, so I added in this feature into version 1.1.1.

    https://github.com/WPprodigy/woocommerce-product-fees/commit/2003850b0f6834050776994b4735809ba59bcb95

    gadgetx

    (@gadgetx)

    Hi all,
    Great plugin, thank you to the developer for taking time to create this.
    I found a bug just like explained above.
    The problem is the fee will calculate for items with similar names eg evie bottled water fee £3, evie cookies fee £2, evie mixed herbs £5 etc but soon as an item with a different name is added to cart eg cosmo ice cream fee £6 etc it won’t calculate the fee for the cosmo ice cream leaving the total fee in the cart as £3+£2+5=£10 rather than £3+£2+£5+6=£16.
    I hope this makes sense.

    https://www.ads-software.com/plugins/woocommerce-product-fees/

    Plugin Author Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    Hi gadgetx,

    I’m not sure I understand. When you have 3 different fees, they all three get added. But on the fourth fee it is not getting added?

    gadgetx

    (@gadgetx)

    Yes, that’s right.

    Plugin Author Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    I cant’ replicate this issue. Adding 4 fees works fine for me: https://cld.wthms.co/1fcMe/2wipRWuW

    Am I missing something? Perhaps try explaining your issue again with a bit more detail.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Bug with duplicate fee names.’ is closed to new replies.