Answer the question
In order to leave comments, you need to log in
How to skip the transition to the product card?
Hello. There is a landing. Created 2 virtual goods. On the landing page, there are 2 descriptions of these products and 2 pay buttons under each description, respectively.
I added links to my products to the buttons. And when you click on one of the pay buttons, a card for this product opens, then the add to cart button and after the payment button.
What I did - I added a plugin (WooCommerce Direct Checkout) for a direct transition to payment, bypassing the cart (so that there are fewer actions for virtual goods, it makes no sense to add them to the cart, they are piece-by-piece). That is, after clicking the add to cart button (changed its text to pay), the product is automatically added to the cart and the checkout form opens, without going to the cart.
What I want to do now is when you click the initial pay button on the landing page so that the product card does not open, and then you need to click pay and there will be a transition to checkout. And immediately when you clicked pay, without opening the card, the design was opened. So real?
I tried to do it this way - I copied the button code in the product card (pay) through the element editor and added it to the site instead of the first button. Removed the button with the transition to the product map. As a result, a button appeared, which is in the product card and it seems that even when clicked, the ordering process opens immediately. In fact, he simply transferred it from the product card to the home screen. But the problem is that if the client does not place an order immediately, but returns to the main page, then by pressing the pay button again, the order does not open, but the main page opens.
In short, in short, you need to link 1 product to 1 button and when you click it, the checkout opens. And at the same time, if you exit and do not draw up, then when you click on the button again, the design opens again. Now if you exit, then just the main page loads when you click checkout.
Answer the question
In order to leave comments, you need to log in
Why fence a garden?
1. In order to add a product to the cart from anywhere, you need to use the link https://my-domain/?add-to-cart=120 where 120 is the id of the product being added.
2. To redirect the user to the cart after that, use the link https://my-domain/cart/?add-to-cart=120 where 120 is the id of the product being added.
3. You can send the user directly to the checkout page using the link https://my-domain/checkout/?add-to-cart=120 where 120 is the id of the product being added.
4. You can also add a certain amount of goods to the cart at once by adding &quantity=5 to the link, it should turn out like this https://my-domain/cart/?add-to-cart=120&quantity=5
In general, I solved the issue in this way. Maybe someone will come in handy.
In the product card, we have an add to cart button. It is there by standard.
We save the link of this button.
Next, we add this link to the button we need. In my case, as described in the first topic, it was necessary to display a button on the main page, after clicking on which the product design would open, without going to the card, then to the basket, and so on.
And finally, add the code to the functions.php file -
function add_to_cart_redirect( $url ) {
$url = wc_get_checkout_url();
return $url;
}
add_filter( 'woocommerce_add_to_cart_redirect', 'add_to_cart_redirect' );
Thus, when we click on the order button, the desired product is added to the basket and immediately proceeds to checkout.
The only thing that I could not solve for the ideal option is that if the client does not immediately place an order, but goes back to the main page, then the next time he clicks on the order button, he will open a page with all the products and there will be an inscription, you cannot add this product to the basket, since it is already there and there will be a button to view the basket. You will have to click to view the basket and then click to place an order. Well, in fact, those actions that I want to avoid).
This is due to the fact that the path of the product goes through the cart, as I understand it, in any case, it is built into woocommerce. Therefore, this is how it works.
But still, if anyone knows a way to get around this moment, write)
PS. Those who want to suggest a plugin - Buy one click WooCommerce. He doesn't fit. Already yuzal, it works as it should only with one product. When creating buttons for different products, it immediately breaks down. It is ideal for the option with product cards. It will work as it should. But I don’t need cards, since the landing page and product description are already on it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question