Add an external/affiliate product to cart on WooCommerce - php

Working on a client's website which uses External products that link to an enquiry form further down on the page. I would like to add this product to the cart when the form is submitted.
I have tried just adding "?add-to-cart=[product-id]&quantity=1" to the end of the URL when the submit button is clicked, where [product-id] corresponds to the current product's ID but it just pops up with a message saying
"Sorry, this product cannot be purchased."
I just need the name of the product to be added to the cart with no price attached.
As clarification, the user will not be charged. It will send the order confirmation to the admin and customer, total price and payment will be arranged offline.
Any help would be massively appreciated.

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.

woocommerce - validate items in cart page before proceed to checkout page

I'm validating the maximum number of products a user can buy per day.
I could limit the number of products by woocommerce_add_to_cart_validation and woocommerce_after_cart_item_quantity_update and it works fine.
the problem is when the user increases the quantity of a product without pressing the "recalculate the cart" button and after that press the "proceed to checkout" button, there will be no warning or error, I know the cart is not get updated but is there a way to show a warning to the user about the number of products in the cart, even when the user does not press recalculate button?
Update:
if the user is guest and login to site after placing his orders woocommerce_after_cart_item_quantity_update and woocommerce_add_to_cart_validation wont fire.
how can I check the quantity of products and redirect him to the cart page (if needed) and show an error before allowing him to enter the checkout page?

add apply coupon link to woocommerce customer payment page

I have developed a system to create orders programmatically in woocommerce. However when a customer clicks on the link to go to their payment page it does not show the 'Have a Coupon' input box. I haven't adjusted any of the templates.
Any ideas on how I can get the coupon input box to appear on the customer payment page?
Location I am talking about is:
<mywebsite>/checkout/order-pay/<order_id>/?pay_for_order=true&key=<order_key>
Thank you for any help with this, I am struggling with it
Payment page is an endpoint, so must apply coupon before it reaches this point

Show three products in cart popup - Woocommerce

I need to show three products in cart page. Now when customer adds a product to cart there is a popup appears which contains current cart details. But what i need is, i need to show three optional products in that cart popup. If user added those product, then cart details should updated. Am using "WooCommerce WooCart Popup Lite" plugin for cart Popup.

How to show all products category wise in shopping cart summary page in prestashop

I am new to prestashop
I want to show all the products in prestashop in my cart summary page.
Even though the customer doesn't ordered a product, it should be displayed in his/her shopping cart summary page with quantity as 0. So that from there he must be able to add quantity if he needs.
The product must be displayed category wise.
NB: I have searched and couldn't find a solution :-(
I think, you should not use cart, but should use template for product category instead of cart. This template make you able to show cart quantity. Cart will "invisible" in your shop. The user will select quantity of goods, all of them will add to the cart on 'onchange' event. When, the user press "Order" button and go to the real cart where he see the summary order information and confirm his order. Shop without traditional cart will inconvenient, because selected goods will in the different categories of the shop
The result will like this: http://screencast.com/t/8csYCudqD
Use ajax command which using on 'Add to cart' button click on 'onChange' event for input with good's count (simple jquery ajax)

Categories