Get fieldset information if customer changes quantity in Woocommerce cart?

Home Forums Ticket Products Event Tickets Plus Get fieldset information if customer changes quantity in Woocommerce cart?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1257936
    Adam
    Participant

    Hi,

    I have fieldsets triggered when a customer orders tickets. As they change the quantity up/down, the number of fieldset forms that appear increase / decrease accordingly as expected.

    However, once the customer clicks “add to cart”, they are sent to the Woo Basket page. The customer can then change the quantity there too. However, because it’s outside of Event Tickets Plus at that point (I presume), no additional fields are captured if the customer increases the quantity.

    Is this a bug / oversight – or is it simply that ETP is not in control at that point? If the latter, are these my options:

    • Make Qty field in the Woo basket read-only with an info message telling customer if they need to change quantities to remove the order from the basket and start over? Or,
    • Bypass the basket and go straight to the Checkout, Or
    • Something else?

    Thanks.

    • This topic was modified 7 years, 1 month ago by Adam. Reason: clarification of one of the bullet points
    #1258481
    Trisha
    Member

    Hello Adam!

    Sorry to hear about this, I understand the concern as it’s not very intuitive when you need to add tickets that have additional fields like you mention.

    Are you showing attendee information on the ticket page? If so, my suggestion would be to have a message for the customer that if they need to change quantities they can add the additional information to their ticket after they place the order. They can view that information by clicking the ‘View my Tickets’ link on the event page.

    If you’re not showing attendees then your suggestion to start over would be better.

    I will log a bug ticket for this issue. I can’t make any promises but we will see what we can do to resolve this issue in due time. In the meantime I will let you know if I find any better solutions!

    Cheers,
    Trisha

     

    #1258540
    Adam
    Participant

    Hi

    I think you misunderstand.

    All is working as expected regarding the customer providing field info on the Event page. It’s just once they have added it to the Woo cart. By default the woo cart allows for quantities to be changed, and if the number is increased on that page then no fieldset info form is triggered to display.

    On further looking I did find a GIT snippet some of your guys had written that makes the cart page treat the quantities of Event Ticket Plus products only as read-only. That does the job in terms of making sure I won’t get tickets ordered without mandatory customer provided information. I have simply added a note at the top of the cart page that says “NOTE: For ticket products you CANNOT change ticket quantities in this shopping cart. If you wish to change the quantities, please remove the ticket(s) in question from the basket (click the red cross), and then return to the event to re-add the ticket(s) with the correct quantities.”

    For completeness the code snippet is below too:

    /**
     * Make WooCommerce cart Quantity input field non-editable (readonly) ONLY FOR Event Tickets Plus products
     * By Matt B and Cliff P
     * From https://gist.github.com/cliffordp/66bf05df61ee269c60ff20d6f39e2cab
     */
    function cliff_etplus_woo_cart_quantity_readonly() {
    
        if ( ! class_exists( 'Tribe__Tickets_Plus__Commerce__WooCommerce__Main' ) ) {
            return;
        }
    
        $args = array(
            'post_type' => 'product',
            'fields' => 'ids',
            'meta_query' => array(
                array(
                    'key' => Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance()->event_key,
                    'value' => 0,
                    'compare' => '>',
                ),
            ),
        );
    
        $product_ids_readonly = get_posts( $args );
        
        $product_ids_readonly = array_unique( $product_ids_readonly );
    
        if ( ! count( $product_ids_readonly ) ) {
            return;
        }
    
        wp_enqueue_script( 'jquery' );
        ?>
        <script>
            jQuery( function( $ ) {
                var product_ids = <?php echo json_encode( $product_ids_readonly ); ?>;
                var $remove_links = $( 'body.woocommerce-cart .woocommerce tr.cart_item td.product-remove a' );
                $remove_links.each( function() {
                    var product_id = parseInt( $( this ).data( 'product_id' ), 10 );
                    if ( -1 === $.inArray( product_id, product_ids ) ) {
                        return;
                    }
    
                    var $row = $( this ).closest( 'tr' );
                    $row.find( 'td.product-quantity input' ).attr( 'readonly', true );
                } );
            } );
        </script>
        <?php
    }
    add_action( 'wp_head', 'cliff_etplus_woo_cart_quantity_readonly' );
    
    • This reply was modified 7 years, 1 month ago by Adam. Reason: Removed opening PHP tag as that shouldn't be included when adding to functions.php
    #1259156
    Trisha
    Member

    Hi Adam!

    Thank you for sharing your solution. I apologize, I understood what you meant I just didn’t convey my thoughts very well. However, I’m very glad you were able find the solution you needed!

    I’m going to go ahead and close this out now but if you have any further questions feel free to let us know!

    Cheers,
    Trisha

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Get fieldset information if customer changes quantity in Woocommerce cart?’ is closed to new replies.