slny311

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 31 total)
  • Author
    Posts
  • slny311
    Participant

    I got the function to work but it seems like the plugin has one big flaw when it comes to adding tickets over the maximum stock number.
    Example:
    Stock left = 4;
    Cart contains 2 tickets;
    User go to event to add 4 more tickets -> add tickets to cart;

    (backend function doesn’t add the metadata for any tickets that goes over the limit)
    resulting in transient data not matching the woocommerce cart quality.
    below is the URL and Code

    Event Link

    
    $transient = 'tribe_tickets_meta_' . $_COOKIE['tribe-event-tickets-plus-meta-hash'];
    $data = get_transient( $transient );
    if ( empty( $data ) || is_scalar( $data ) ) {
    $data = array();
    }
    if($ticketevent){
    								echo '<ul class="cart-ticket-list">';
    								foreach($data[$product_id] as $ticketkey=>$singledata){
    									echo '<li>';
    									foreach($singledata as $key=>$singlemeta){
    										echo ($key == 'member-name' ? $singlemeta : '' );
    										echo ($key == 'first-name' ? $singlemeta .' ' : '' );
    										echo ($key == 'last-name' ? $singlemeta : '' );
    									}
    									echo '<a href="#" onClick="metaRemove(' . $product_id . ',' . $ticketkey . ',this);return false;"><small>remove</small></a>';
    									echo '</li>';
    								}
    								echo '</ul>';
    							}
    <script>
    function metaRemove(product_id, ticketkey,e){
    							$(e).html('<small class="blue">Pending</small>');
    							$.ajax({
    							  url: se_ajax_url + '?action=ticket_meta_ajax&pid=' + product_id + '&tid=' + ticketkey
    							}).done(function(data) {
    							  var curval = $('.pid' + product_id + ' input.qty').val();
    							  $('.pid' + product_id + ' input.qty').val(curval-1);
    							   $('.pid' + product_id + ' input.qty').change();
    							   $(".button[name=update_cart]").click();
    							});
    						}
    				</script>
    function ticket_meta_ajax() {
    	$ticket_meta_expire_time = 86400;
    	$transient = 'tribe_tickets_meta_' . $_COOKIE['tribe-event-tickets-plus-meta-hash'];
    	$data = get_transient( $transient );
    	$product_id = sanitize_text_field($_REQUEST['pid']);
    	$ticket_key = sanitize_text_field($_REQUEST['tid']);
    	$temparray = $data[$product_id];
    	array_splice($temparray,$ticket_key,1);
    	$data[$product_id] = $temparray;
    	set_transient( $transient, $data, $ticket_meta_expire_time );
    	die;
    }
    • This reply was modified 7 years, 5 months ago by slny311.
    in reply to: Ajax Add to Cart instead of going to Cart Page #1190649
    slny311
    Participant

    Just incase – Below is what I used.

    public function process_front_end_tickets_form() {
    		parent::process_front_end_tickets_form();
    
    		global $woocommerce;
    
    		if ( empty( $_REQUEST['wootickets_process'] ) || intval( $_REQUEST['wootickets_process'] ) !== 1 || empty( $_POST['product_id'] ) ) {
    			return;
    		}
    
    		foreach ( (array) $_POST['product_id'] as $product_id ) {
    			$quantity          = isset( $_POST[ 'quantity_' . $product_id ] ) ? intval( $_POST[ 'quantity_' . $product_id ] ) : 0;
    			$optout            = isset( $_POST[ 'optout_' . $product_id ] ) ? (bool) $_POST[ 'optout_' . $product_id ] : false;
    			$passed_validation = apply_filters( 'woocommerce_add_to_cart_validation', true, $product_id, $quantity );
    			$cart_data         = array(
    				'attendee_optout' => $optout,
    			);
    
    			if ( $passed_validation && $quantity > 0 ) {
    				$woocommerce->cart->add_to_cart( $product_id, $quantity, 0, array(), $cart_data );
    			}
    		}
    		wp_redirect( "http://$_SERVER[HTTP_HOST]/cart/" );
    		exit;
    	}

    You Guys actually already have this code in event-tickets-plus/src/tribe/commerce/edd/main.php
    but doesn’t seem to carry over to the child function.

    public function process_front_end_tickets_form() {
    		// We're only interested in EDD Tickets submissions
    		if ( ! isset( $_GET['eddtickets_process'] ) || empty( $_POST['product_id'] ) ) {
    			return;
    		}
    
    		// Add each ticket product to the cart
    		foreach ( (array) $_POST['product_id'] as $product_id ) {
    			$quantity = isset( $_POST[ 'quantity_' . $product_id ] ) ? (int) $_POST[ 'quantity_' . $product_id ] : 0;
    			if ( $quantity > 0 ) $this->add_ticket_to_cart( $product_id, $quantity );
    		}
    
    		// To minimize accidental re-submissions, redirect back to self
    		wp_redirect( edd_get_checkout_uri() );
    		edd_die();
    	}
    slny311
    Participant

    How come I get an empty array even though I see the cookie already got created ( webdev tool cookie inspector )

    slny311
    Participant

    Hi Brook, I haven’t read your reply yet. let me dig deeper into your reply.

    -edit
    Ok I have read your reply and yes that is correct.
    To get this to work I would need to read the Cart meta after forms are being submitted and Before They move to the checkout or payment portion.

    So the first step I need is being able to read those data stored in the cookie?

    • This reply was modified 7 years, 5 months ago by slny311.
    slny311
    Participant

    Update:

    The Code posted above only works when user already checked out with their order.

    From the code located in:
    \event-tickets-plus\src\Tribe\meta\Storage.php
    public function get_meta_data_for( $id )

    I see that the data is stored in here
    $transient = self::TRANSIENT_PREFIX . $_COOKIE[ self::HASH_COOKIE_KEY ];
    but I am having trouble trying to obtain this data in my version of the code.

    $transient = ‘tribe_tickets_meta_’ . $_COOKIE[‘tribe-event-tickets-plus-meta-hash’];
    $data = get_transient( $transient );
    print_r($data);

    slny311
    Participant

    can you explain how you got your variable $ticket array?
    I cannot find any $ticket->qr_ticket_id in all of the data i pulled from cart.

    so when I use those function with the cart’s item product id, I get an empty array back.

    slny311
    Participant

    Hi

    The above code looks for order that has already been purchased?
    What I need is to get the Metadata when they are still sitting in the cart, so I can modify how the cart page works and maybe make them into different variations of the same product so that each tickets are independent.

    Shouldn’t I be accessing the session data in the cart to get these meta? how do I look for that in this plugin?

    My data below v
    $items = $this->get_cart_for_session();
    $_product = $values[‘data’]->post;
    $values[‘product_id’]<- this is the id I am using to pull these data

    $meta_fields
    Tribe__Tickets_Plus__Meta__Field__Text Object ( [type] => text [id] => [label] => Member Org [slug] => member-org [required] => [ticket_id] => 3500 [extra] => Array ( ) [field_type_name] => Array ( [checkbox] => Checkbox [radio] => Radio [select] => Dropdown [text] => Text ) [post] => WP_Post Object ( [ID] => 1054 [post_author] => 545 [post_date] => 2016-02-17 11:51:26 [post_date_gmt] => 2016-02-17 16:51:26 [post_content] => the content here [post_title] => LIREG Golf and Tennis Outing [post_excerpt] => [post_status] => publish [comment_status] => open [ping_status] => closed [post_password] => [post_name] => lireg-golf-and-tennis-tournament [to_ping] => [pinged] => [post_modified] => 2016-10-24 17:21:35 [post_modified_gmt] => 2016-10-24 21:21:35 [post_content_filtered] => [post_parent] => 0 [guid] => http://5cf.563.mwp.accessdomain.com/?post_type=tribe_events&p=1054 [menu_order] => 0 [post_type] => tribe_events [post_mime_type] => [comment_count] => 0 [filter] => raw ) )
    $meta_data
    Array ( [0] => Array ( [type] => text [required] => [label] => Member Name [slug] => member-name [extra] => Array ( ) ) [1] => Array ( [type] => text [required] => [label] => Member Org [slug] => member-org [extra] => Array ( ) ) [2] => Array ( [type] => text [required] => [label] => Member Email [slug] => member-email [extra] => Array ( ) ) )

    • This reply was modified 7 years, 5 months ago by slny311.
    slny311
    Participant

    That is Fine but is there a way to get those Form meta data from the current cart?
    (in cart page and not in cart page)

    I need to grab the name and email info from those grouped tickets.
    I will tackle on separating the woo-commerce cart if I am able to get all the info I need.

    Currently I am having trouble finding where you guys keep those Meta data attached to each individual tickets, since they aren’t an item data meta in cart?

    in reply to: Ajax Add to Cart instead of going to Cart Page #1187371
    slny311
    Participant

    forcefully set Quality back to 0 on single event load prevents it from keeping the old values and showing up new ticket forms when pressing the back button

    upon process_front_end_tickets_form()

    I Just add a new redirect header to prevent data being kept on the cart page which causes new items to be added to cart when user refresh this page.

    slny311
    Participant

    wrong topic
    This isn’t resolved I miss-clicked the button

    • This reply was modified 7 years, 6 months ago by slny311.
    • This reply was modified 7 years, 6 months ago by slny311.
    in reply to: Get All Attendee's Email Address #1186988
    slny311
    Participant

    Finished this part of coding project after reading through how your private function gets the csv exports.

    function se_lookup() {
        global $wpdb;
    
        $search = sanitize_text_field($_REQUEST['q']);
        $event_id = sanitize_text_field($_REQUEST['id']);
    	do_action( 'tribe_events_tickets_generate_filtered_attendees_list', $event_id ); 
    	$items = Tribe__Tickets__Tickets::get_event_attendees( $event_id );
    	$emailstring = '';
    	foreach( $items as $item ){
    		$ticket_meta  = get_post_meta( $item['attendee_id'],'_tribe_tickets_meta', true );
    		foreach ($ticket_meta as $key=>$single_meta){
    			if(($key=='email-address')||($key=='member-email')){
    				$emailstring .= $single_meta . ', ';
    			}
    		}
    	}
        $args = array(
    		'search' => '*'. $search .'*'
    	);
    	$wp_user_query  = new WP_User_Query( $args );
    	$users = $wp_user_query->get_results();
    		foreach ($users as $user) {
    			if ((wc_memberships_is_user_active_member($user->ID, 'member')) && (strcmp($user->user_email, $emailstring)>0) ){
    				if (get_user_meta($user->ID, 'directory_company_name', true)){
    					$user_org = ' | ' . get_user_meta($user->ID, 'directory_company_name', true);
    				} else { $user_org = " | N/A"; }
    				echo $user->first_name . ' ' . $user->last_name  . $user_org . "<span style='display:none;'> | ". $user->user_email."</span>\n";
    			}
    		}
        die();
    }
    in reply to: Get All Attendee's Email Address #1186558
    slny311
    Participant

    This reply is private.

    • This reply was modified 7 years, 6 months ago by slny311.
    • This reply was modified 7 years, 6 months ago by Brook.
    in reply to: Get All Attendee's Email Address #1186509
    slny311
    Participant

    This will generate a list of attendees, and from there you would have the data you need to filter with. Does that look right to you?

    Yes I need to be able to access that function which returns an array for excel output.
    I can just filter the list with that listing.

    That sounds like a bug. I see that it’s been logged a few days back, so it’s one we plan to address. To be up front I would not be surprised if it takes a while to fix that though. Users to rarely press the refresh button, it is unlikely to impact the extreme majority of sites. Plus a lot of browsers warn you when resbumitting data like that, indicating that unexpected behavior might happen. Thus this would naturally be a lower priority bug then one that impacts more users.

    Please let me know if you have any more questions. Cheers!

    I will be looking into ajaxing the add to cart part of the plugin.

    in reply to: Get All Attendee's Email Address #1185713
    slny311
    Participant

    Any status update on this?

    in reply to: Ajax Add to Cart instead of going to Cart Page #1185712
    slny311
    Participant

    Any update ?

    I think a workaround would be having a ajax add to cart button but I didn’t see that function for your event ticket plugin.

Viewing 15 posts - 1 through 15 (of 31 total)