WooCommerce: Checkout expiration not working

2019-08-25 18:42发布

问题:

I've a website with WooCommerce installed. On my website I'm using CRED to allow my users to create products in my Shop (so they need to pay for this via the WooCommerce checkout).

When I fill out the CRED Toolset form now and press "Pay to create product", I'm getting redirected directly to the WooCommerce checkout.

When I close the page now (without continuing the payment) and come back 2 days later, the checkout is still there with the "product" in it. Because I don't want this, I've added this function here to clean the checkout after 2 hours but I've tried it and it don't works (the checkout is still available after days):

/**
 * Checkout and cart expiring
 */
add_filter( 'wc_session_expiring', 'wc_session_expiring' );
function wc_session_expiring( $seconds ) {
    return 60 * 60 * 1;
}

/**
 * Checkout and cart expired
 */
add_filter( 'wc_session_expiration', 'wc_session_expired' );
function wc_session_expired( $seconds ) {
    return 60 * 60 * 2;
}

So what can I do to clean the checkout after 2 hours waiting for the user to press the "Pay now" button?