-
CF7 WooCommerce Integration
1- JS code for Page
<script> document.addEventListener( 'wpcf7mailsent', function( event ) { if (document.getElementsByName("radio-232")[0].checked){location = 'https://learn.sb1.wpokulu.club/?add-to-cart=14';} if (document.getElementsByName("radio-232")[1].checked){location = 'https://learn.sb1.wpokulu.club/?add-to-cart=16';} if (document.getElementsByName("radio-232")[2].checked){location = 'https://learn.sb1.wpokulu.club/?add-to-cart=15';} }, false ); </script>
2- PHP code for redirect Checkout Page
// Woocommerce redirect after add to cart push function bbloomer_redirect_checkout_add_cart( $url ) { $url = get_permalink( get_option( 'woocommerce_checkout_page_id' ) ); return $url; } add_filter( 'woocommerce_add_to_cart_redirect', 'bbloomer_redirect_checkout_add_cart' ); add_filter( 'woocommerce_subscription_add_to_cart', 'bbloomer_redirect_checkout_add_cart' );
3- PHP code for only one product in cart
// before addto cart, only allow 1 item in a cart add_filter( 'woocommerce_add_to_cart_validation', 'woo_custom_add_to_cart_before' ); function woo_custom_add_to_cart_before( $cart_item_data ) { global $woocommerce; $woocommerce->cart->empty_cart(); // Do nothing with the data and return return true; }
Log in to reply.