Forum Replies Created

Viewing 15 replies - 1 through 15 (of 47 total)
  • Thread Starter marketing guy

    (@el-terrible-bmw)

    Thank you so much @mrclayton

    This is the final code I have that does what I need. Works well and tested.

    add_filter( 'wc_stripe_force_save_payment_method', '__return_true', 10, 3 );
    
    add_action('woocommerce_pre_payment_complete', 'create_customer_in_stripe', 10, 1 );
    function create_customer_in_stripe ($order_id) {
    	$order = wc_get_order($order_id);
    	$payment_method = WC()->payment_gateways()->payment_gateways()[$order->get_payment_method()];
    
    	// if the order has a customer ID, then a Stripe customer already exists to return
    	if ($order->get_customer_id) {
    		return;
    	}
    
    	// If order is not using Stripe CC payment method, do not create a customer
    	if ($order->get_payment_method() != 'stripe_cc') {
    		return;
    	}
    
    	$result = \WC_Stripe_Customer_Manager::instance()->create_customer( WC()->customer );
    	
    	if ( ! is_wp_error( $result ) ) {
    		$order->update_meta_data( \WC_Stripe_Constants::CUSTOMER_ID, $result->id );
    		$order->save();
    
    		// Save the payment method.
    		$result = $payment_method->create_payment_method( $order->get_meta( \WC_Stripe_Constants::PAYMENT_METHOD_TOKEN ), $result->id );
    	}
    }
    Thread Starter marketing guy

    (@el-terrible-bmw)

    Thanks @mrclayton.

    One more thing, can you tell me what context this is supposed to be in?

    $this->payment_method->create_payment_method()

    Is it WC_Payment_Gateway_Stripe_CC? I’m trying to see how to access it but most of the methods aren’t static and it doesn’t appear to have a static way to access it.

    Thread Starter marketing guy

    (@el-terrible-bmw)

    Hello @mrclayton,

    I’ve seen that filter, but it doesn’t actually appear to save the payment info/customer without user’s registering on the website.

    I see $user_id mentioned in many places that actually create a Stripe customer.

    Normally in Stripe, you can create a customer without sending any info to Stripe. I’m trying to force customer creation/payment method saving for future usage if needed independent of users creating accounts or checking out as a guest.

    Let me know if that is still supposed to work.

    Thread Starter marketing guy

    (@el-terrible-bmw)

    Ahh yes, I forgot about specifying the number of parameters. Sorry about that.

    BTW the filter I’m using is tablepress_table_output.

    This new version has a bunch of issues in the admin section. It even screws up adding new posts, I simply cannot add any new posts until I disable the plugin. If I try to save a post, it just deletes all content and saves an empty post.

    I just commented out this line get_currentuserinfo(); line in admin/includes/data_options.php like this:

    //get_currentuserinfo();

    I’m not sure what that’s used for but hopefully plugin author will fix it. Also what Roberto Villerreal wrote didn’t fix mine, I still got various auth and cookie errors. plus it sounds like that function is deprecated so the plugin will need to be fixed not to use any deprecated elements.

    Thread Starter marketing guy

    (@el-terrible-bmw)

    Nah the TablePress formulas won’t really work, at least not for a part of it.

    What I might do is just create a small JS script that does this on the table edit page and then I can just save the table after running the JS script.

    Thread Starter marketing guy

    (@el-terrible-bmw)

    No I won’t need to scale this up. The reason I wanted to organize it somehow instead of just having raw code was purely for code management. i.e. if I have 100 div tags and need to make a change to each, I would have to do that. If it was dynamically outputted, I would just have to change the markup in one place.

    Thread Starter marketing guy

    (@el-terrible-bmw)

    Ok thanks again Tobias.

    I was able to figure it out. If anyone else is looking for a similar thing, you can just use this:

    add_filter( 'tablepress_table_render_data', 'tablepress_hide_colummns' );
    
    function tablepress_hide_colummns( $table ) {
    
    	$table_headers 	= $table['data'][0];
    	$total_columns 	= count($table_headers);
    	$table_data 	= $table['data'];
    
    	if ($total_columns == 8) {
    
    		// Loop through and delete columns 1 and 6
    		foreach ($table_data as &$row) {
    			unset($row[1]);
    			unset($row[6]);
    			$row = array_values($row);
    		}
    
    		$table['data'] = $table_data;
    
    	}
    
    	return $table;
    }
    Thread Starter marketing guy

    (@el-terrible-bmw)

    There are 116 products. The website gets about 3-4k pageviews per day.

    I think the problem comes from these 3 timeout transient types because they’re all autoloaded. I imagine when there’s like 70k of each, and they’re all autoloaded, that’s like 210k rows in the PHP’s memory? That’s usually when I’ve noticed the website is extremely slow or unresponsive and I end up having to manually delete the transients (i.e. every 2 weeks or so.)

    _transient_timeout_wc_rating_count%
    _transient_timeout_wc_review_count%
    _transient_timeout_wc_average_rating%

    This has only started happening for like 4-6 weeks so it wasn’t an issue before.

    Also many of these transients have the exact same option_name and option_value value. Is that supposed to be? Seems weird that it would be there multiple times.

    https://s13.postimg.org/q5eoxhitj/wc_transients.png

    Thread Starter marketing guy

    (@el-terrible-bmw)

    I think the problem is that most of these transients are not even expired so those plugins do not delete them. However, I do not understand why rating, review, and average reviews need thousands of transients anyways.

    It’s either a WooCommerce bug or some other plugin is causing the issue. Do you mind posting a full list of plugins you have installed so I can see if any match? Also, perhaps where your hosting the website?

    Thanks

    Thread Starter marketing guy

    (@el-terrible-bmw)

    Here’s actually a breakdown of total rows for each transient type, most of which have been accumulated over the past 8 days:

    _transient_wc_rating_count% = 33,073
    _transient_wc_review_count% = 5,024
    _transient_wc_average_rating_% = 33,073
    _transient_timeout_wc_rating_count% = 33,101
    _transient_timeout_wc_review_count% = 5,024
    _transient_timeout_wc_average_rating% = 33,101

    Thread Starter marketing guy

    (@el-terrible-bmw)

    I have not. I did noticed that 2.3.7 got released so maybe it got fixed in that version.

    Thread Starter marketing guy

    (@el-terrible-bmw)

    Ok sounds great. Thanks for the explanation.

    Thread Starter marketing guy

    (@el-terrible-bmw)

    Thanks Tobias.

    I did actually find that and was contemplating using it, but my tables are pretty long so I figured having caching on is not such a bad idea. heh.

    I think I’ll just wait for it to reset itself since I’m not in a rush. Also, regarding my other question, does cache reset at the same time for all tables, or does each table have it’s own time keeping at which that 12 hour reset is done? Just want to know for my curiosity.

    Thanks again for the awesome plugin. Easily one of my favorite WordPress plugins and probably the best support.

Viewing 15 replies - 1 through 15 (of 47 total)