Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #852540

    Hello,
    we have set a wordpress eshop using woocomerce AND enfold.

    Also we used the plugin bellow to create a custom field to product.
    WC Fields Factory (https://wordpress.org/plugins/wc-fields-factory/).

    We have create a custom field (Yes/No), and if customer select Yes, add to product price a addition price.
    The code which we are use

    function calculate_gift_wrap_fee( $cart_object ) {  
        if( !WC()->session->__isset( "reload_checkout" )) {
            /* Gift wrap price */
            $additionalPrice = 100;
            foreach ( $cart_object->cart_contents as $key => $value ) {
    			if($value['wccpf_led']!=NULL && $value['wccpf_led']=='yes') {
    				$orgPrice = floatval( $value['data']->get_price() );
    				$value['data']->set_price( $orgPrice + $additionalPrice );
    			   // echo  $value['data']->get_price();
    			}
            }   
        }   
    }
    add_action( 'woocommerce_before_calculate_totals', 'calculate_gift_wrap_fee', 99 );

    The problem is the additionPrice added twice on cart page.
    On cart icon on menu works correctly, but when we open the cart page addition price added twice.

    For exampe
    Product price: 200
    Addition Price: 50
    Cart Icon on Header: 250 (Correct)
    Cart page(list with price): 300 (200+50+50)

    #853133

    Hey tesseram,
    I see your trying to build a gift wrap option, have you thought about using a plugin such as: Woocommerce Gift Wrapper

    Best regards,
    Mike

    #853304

    Hello and thank you for help,
    but we want to have two extra options(gift wrap & extra fee ex. special “something” YES/NO ). So we can’t use this plugin. Have you any suggestions about the code?

    Best Regards.

    #854043

    Hi,

    Please contact the plugin author to help you out with the integration
    It will be the best way for it.

    Thank you very much

    Best regards,
    Basilis

    #854414

    There is no plugin. Just this function.
    We have try with other theme and works correctly. When active enfold again we have the same problem.

    Have you any other suggestion.

    Thank you very much for your help.

    Best Regards.

    #854481

    Hi tesseram,

    Can you give us temporary admin access to your website in the private content box below, so that we can have a closer look?

    And you have additional price set to 100
    https://cl.ly/402b092S312U

    Best regards,
    Victoria

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