Support » Plugin: Extra Product Options (Product Addons) for WooCommerce » Individually sold not working after update

  • Resolved schnolly

    (@schnolly)


    Yesterday I’ve updated to version 2.0.5.
    After this update the function ‘individually sold’ is not working anymore for products with extra option fields.
    If I enter a different values it’s possible to buy the product more than once.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author ThemeHigh

    (@themehigh)

    Please try to add the below hook in your child theme’s functions.php.

    function thwepof_enable_sold_individually($cart_id, $product_id, $variation_id, $variation, $cart_item_data){
        if($product_id == Your_product_id){
            unset($cart_item_data['thwepof_options']);
            unset($cart_item_data['unique_key']);
            
            THWEPOF_Utils::write_log($cart_item_data);
            
            $id_parts = array( $product_id );
    
            if ( $variation_id && 0 !== $variation_id ) {
                $id_parts[] = $variation_id;
            }
    
            if ( is_array( $variation ) && ! empty( $variation ) ) {
                $variation_key = '';
                foreach ( $variation as $key => $value ) {
                    $variation_key .= trim( $key ) . trim( $value );
                }
                $id_parts[] = $variation_key;
            }
    
            if ( is_array( $cart_item_data ) && ! empty( $cart_item_data ) ) {
                $cart_item_data_key = '';
                foreach ( $cart_item_data as $key => $value ) {
                    if ( is_array( $value ) || is_object( $value ) ) {
                        $value = http_build_query( $value );
                    }
                    $cart_item_data_key .= trim( $key ) . trim( $value );
    
                }
                $id_parts[] = $cart_item_data_key;
            }
            
            $cart_id = md5( implode( '_', $id_parts ));
        }
        
        return $cart_id; 
    }
    add_filter( 'woocommerce_cart_id', 'thwepof_enable_sold_individually', 10, 5 ); 

    You need to replace Your_product_id with the ID of your product.

    Hope this will help.

    Thank you

    Plugin Author ThemeHigh

    (@themehigh)

    We hope your issue is resolved now.

    We are going to mark this thread as resolved.

    Thank you!

    Thread Starter schnolly

    (@schnolly)

    I’m sorry for the late reply. It was a bit hectic because of a deadline for the site to go live.
    We managed to get it to work with another plugin added, a min-max products plugin.
    This is working and the site is live now.

    Many thanks for the reply!

    Plugin Author ThemeHigh

    (@themehigh)

    Thank you for letting us know.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Individually sold not working after update’ is closed to new replies.