Disable Virtual Product

Home Forums Ticket Products Event Tickets Plus Disable Virtual Product

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1091575
    stagetech
    Participant

    I’m using Events Calendar Pro with Event Tickets Plus and WooCommerce.

    My client’s plan has changed a little and they are now going to be selling physical tickets only. I’ve disabled the tickets email with:

    
    // Remove ticket emails
    add_action( 'init', 'wootickets_stop_sending_email' );
    function wootickets_stop_sending_email() {
    	if (class_exists('Tribe__Tickets_Plus__Commerce__WooCommerce__Main')) {	
    		$woo = Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance();
    		remove_filter( 'woocommerce_email_classes', array( $woo, 'add_email_class_to_woocommerce' ) );
    		add_action( 'woocommerce_email_after_order_table', array( $woo, 'add_tickets_msg_to_email' ) );
    	}
    }
    
    // Remove the line about tickets in order emails
    add_filter('wootickets_email_message', 'woo_tickets_filter_completed_order', 10 );
    function woo_tickets_filter_completed_order($text) {
    	$text = "";
     	return $text;
    }
    

    I need to be able to switch off the “virtual product” setting when each ticket product is created with something like update_post_meta( $ticket->ID, '_virtual', 'no' ); but what I’ve tried so far isn’t working. Any ideas?

    #1091605
    George
    Participant

    Hi there,

    We unfortunately cannot help with custom coding projects, but out of curiosity, can you clarify the goal of setting tickets as NOT being virtual products?

    Their status as virtual products is quite essential to the concept of what these tickets are—they are virtual products. Whether you end up printing out tickets or not, the actual “product” being sold is the ticket on the website (a “slot” on the attendees list, essentially).

    Is there anything about the Virtual Product setting specifically that hinders the choice to sell physical tickets? Our plugins only work with the tickets as Virtual Products.

    Let me know what you think of all of this and if you can elaborate a bit on your aims—while we cannot help with customizations, if I better understand your goals I might be able to help write a snippet of code to help.

    Thank you!
    George

    #1091621
    stagetech
    Participant

    Hi George,

    Thanks for the reply.

    My intention with making it a non-virtual product was to return the shipping options and address fields to the checkout process for tickets. If you’re able to suggest how I might do that without changing the virtual product status, that would be awesome!

    #1092047
    George
    Participant

    To the best of my knowledge, @stagetech, there is no way to pull that off. 🙁 I’m sorry about this, but will take a deeper dive into the code here to just how possible this is! I will rope in a more skilled developer to assist me, too.

    Stay tuned—and thank you for your patience!

    George

    #1092096
    stagetech
    Participant

    Thanks George, much appreciated!

    #1093216
    stagetech
    Participant

    I’ve been able to get shipping methods back with add_filter( 'woocommerce_cart_needs_shipping', '__return_true' ); but this forces shipping on all products, including some other virtual products that I don’t need shipping for. I’ve tried a few things to exclude those products but not having much luck!

    Any progress on your end?

    #1093593
    George
    Participant

    There’s unfortunately no progress on my end, @stagetech—I’m sorry for the delayed response, but have been tinkering a bit to no avail. Your solution is a solid one, despite it affecting all other products….

    I’m sorry to disappoint @stagetech! I think from here your best bet is to reach out to WooCommerce-specific support folks: “How can I add shipping to some Virtual Products, but not all?”

    I’ve been unsuccessful in trying to do this. Sorry, @stagetech! 🙁

    — George

    #1093683
    stagetech
    Participant

    Thanks for the update George, and thank you for trying. If I have a breakthrough at some point I’ll let you know!

    #1093702
    George
    Participant

    Thank you @stagetech—much appreciated. I will close this specific thread for now to help keep issues organized, but if you have a breakthrough and want to share it—or have questions about anything else!—don’t hesitate to open a new thread any time.

    Thank you!
    George

    #1096831
    James
    Participant

    I’m doing something very similar, except my client wants the option for virtual and physical tickets.

    My plan is to try and stop making tickets virtual, and then only send the email if they select the virtual delivery method (I have no idea if this is possible yet, some of your code might help).

    I tried using the update post meta, with a post transition hook, but it turned out the was something firing after the hook setting the ticket back to being virtual.

    Anyway, I’ve found that this works:

    /**
    * Stop tickets being virtual
    */
    function make_ticket_physical($post_ID, $post_after, $post_before){
        if($post_after->post_type == 'product'){
            update_post_meta( $post_ID, '_virtual', 'no');
        }
    }
    
    add_action( 'save_post', 'make_ticket_physical', 999999999999999999999, 3 ); 

    Edit: You don’t actually need $post_before

    Now i’ve got to try and work out how to only send the ticket email if they’ve chosen virtual delivery…

    • This reply was modified 10 years ago by James.
    #1097241
    George
    Participant

    Thank you for sharing this, @James!

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Disable Virtual Product’ is closed to new replies.