Second Woocomerece add to cart button - php

I need to create a second button on product pages next to the current add to cart button.
Currently I have a button that says 'Add to basket' and when clicks it adds the product to the basket but doesn't redirect to cart.
The second button needs to add to cart and redirect to the basket or checkout page.
Any ideas on how i can create this button?

you can use javasctip's
button + ajax
submit

Related

How to make [add_to_cart] button without shortcode with quantity field attached

This question comes in two parts:
Create a button that does the same as the woocommerce shortcode [add_to_cart] but without any plugins or shortcodes
Add a quantity field next to the add to cart button that allows the user to add a selected amount of products to their cart.
In essence, I want to circumnavigate the cart page, and have the customer add their product(s) on single pages.
So far, I am able to have a button that links the selected product to the cart page. The cart page is where a user is able to select the quantity of products to add, and add the products to the final checkout page. As stated above, I want to circumnavigate the cart page, and have the user be able to do the same functionality of the cart page, but on a regular page instead.
Here is my button that I have made for that purpose:
<form method="post">
<button class="Payment" name="asbestos_inspector_refresher">Register & Pay With Credit Card</button>
</form>
if(isset($_POST['asbestos_inspector_refresher']))
{
session_start();
$_SESSION['class_name'] = $class_name;
$_SESSION['product_name'] = $product_name;
wp_redirect("https://mwcti.com/Data_Table/?success=yes");
}
EDIT: Data_Table is a blank page before the cart page I made during testing to see if the value for the product would carry over to the cart page.

How to create a shopping cart in php without database?

I need to display the products with add button to add it to the cart.
When user clicks the button, the product will to be removed from the list and appear in the cart section, which is below the section where the available products are displayed.
In the cart section we have the products in the cart and a button to remove the product from cart.
When user click the button, the product will to be removed from the cart section and displayed in the product section, which is above the cart section.
For doing this, you can use the $_SESSION['session_var_name'] variable.
When user click on the add to cart button store the values into session
and display those data from the session on the cart page.
At the cart page you can use the delete button for removing product from cart and for
doing this use unset($_SESSION['session_var_name']) .
I hope this will helps you.

How to add the buy now button to a product with hidden add to cart button?

I have items that are using Woocommerce Product Add-ons. This plugin uses the POST method, however I wanted to keep the Ajax buttons for the other products.
Based on "Remove add to cart button for specific product categories in WooCommerce 3" answer code That removes the add-to-cart button for specific product tags on single product pages, but problem now is I have no button to show.
The code replace also the ajax add to cart button by a button linked to the product and on single product pages, when hitting RETURN/ENTER key, the product is added to cart, which is exactly what I wanted. However, I want to have a Buy Now or Submit button in place. What should I do?

How to display "Add to cart" button even if price is not added in woocommerce in avada theme?

I am using avada 4.0.2 theme.
When I add price of a product, Add to cart button is displayed everywhere where the product is shown but when there is no price added,
then there is no Add to cart button. I want to display "Add to cart" button always even if I don't mention any price in Regular Price column.
Actually I want to display a pop up form on clicking a button. I want to display this button on the place of Add to cart. for this I am using a WooCommerce Email Inquiry & Cart Options LITE plugin which replaces the Add to cart button with Buy Now button which on being clicked displays pop up form.
Now the problem is this button is displayed only when price is added to a product.
I somehow managed to display like I wanted. I could not make Add to cart show always rather I wrote .product-buttons{diaplay:none;} and echo the code of the button in content-product.php used in the plugin.

Woocommerce change "proceed to cart" button with "add to cart" button

In Woocommerce after pressing on “add to cart” button on some product (shop page) it changes its state to “proceed to cart”. It is necessary to change this button behaviour to allow user to add to cart the product one more time (without need to refresh the page or go to cart page). It means that after pressing “add to cart” button once or several times the button should not change it state to allow user to add the product to cart so many times as it needed. How to do it? Any help is greatly appreciated.

Categories