What I would like to do is a this:
A customer buys a product. Instead of "add to cart" it would show "See Digital Product" and have a custom link to a specific page.
I was looking in the database for WooCommerce and trying to figure out how I would know an item is already purchased so I can figure out how to make a function do this automatically:
SELECT * FROM wp_woocommerce_payment_tokens
token_id gateway_id token user_id type is_default
SELECT * FROM wp_woocommerce_order_items
order_item_id order_item_name order_item_type order_id
But I couldn't figure out their logic yet or the right function in WordPress to make this happen.
The only function I could find online is for redirects but this is only right when you purchase the item, not if you go back to the page where you already bought the item:
add_action( 'template_redirect', 'wc_custom_redirect_after_purchase' );
function wc_custom_redirect_after_purchase() {
global $wp;
if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) {
wp_redirect( get_permalink( get_page_by_title( "About" )->ID ) );
exit;
}
}
Please lead me in the right direction.