I'm creating a simple Prestashop module that places a form in CMS pages. That form will return a custom value (and a new product) that I need to be redirected to the cart after clicking a "submit" button.
How can I send the data to the cart?
Thank you!
Rui
Every customer has a unique cart ID.
1 ) After submit put information to mysql table
2 ) hook module to cart step
3 ) Check if this customer and cart id equal and do what you need to do.
I think its easiest and simplest way to do it. Rather than override system files. Even more you talking about module.
There is a javascript class in prestashop to control the cart.
Simply call ajaxCart.add(params)
This function will add the product to the cart with ajax.
Related
How i can add a button on the cart page that will allow the customer to "Empty The Cart". Script will empty contents of the cart.
you could create the button in the template and use a script to call this endpoint: DeleteACart https://developer.bigcommerce.com/api-reference/store-management/carts/cart/deleteacart, to erase an entire cart.
You don't want to use the management api to do this, because that would require authentication. You need to use the storefront cart api I believe.
You would need to call GET /api/storefront/carts and get the id of the cart, and then call DELETE /api/storefront/delete/{id}.
Alternatively you could mimic the native functionality by looping through all the cart items to build a request for POST /remote/v1/cart/update.
The template file for cart in cornerstone is templates/pages/cart.html
In my Prestashop web there are 3 types of products (In stock, On demand and Coming soon). When a user clicks on Add to cart button in product page, it should shows an alert saying the products cannot be mixed (you cannot buy a product in stock and a product on demand). I use BlockCart module but I cant find the file which I have to edit. Also, I have looked in CartController or ProductController but nothing.
Can you help me?
You Can check in controllers/front/CartController.php for processChangeProductInCart Function.
I wonder if there's a way to pass some extra information (attribute) by using custom add to cart button.
We've got clear products with their prices. We also sell the same products with print.
Printed version is more expensive. The product is going out from special generator and there, "add to cart button" will be added to where -if that's possible- I would like to pass attribute to this product (so I could change base price to printed)
Is there any way to pass/add this attribute to the product before it will go to cart?
I think the best way to do that would be use combinations - you can make combination with different prices and then you will be able to send combination_id using your extra button.
I'm using Hotcakes Commerce DNN modules and I'd like to know how I can allow the user to stay on the product page after the "Add to Cart" button is clicked. The default behaviour is to redirect the user to the cart page whenever the a product is added to the cart.
The easiest way to make this happen is to modify your viewset to change how the add to cart buttons work. Here's a summary of the required steps:
Add and begin modifying your viewset if you haven't started already.
Modify your \VIEWSETNAME\Views\Products_ProductDetails.cshtml file to change the add to cart action from a post, to an AJAX link. This will allow you to add products to cart directly using a link, but keep you on the page.
If you're using the Mini Cart, refresh the page using JS so that it updates appropriately.
Please note that this option won't work well if your products have choices. If this is the case, you should instead allow your customers to be directed to the cart page, and use a parameter there to determine whether or not you redirect back to the product page.
I'm developing an integration on a opencart site with an hardcoded solution for calculate a cost of a product according to some input like height width and quantity and other some hidden value.
so
I'm trying to edit the add action for the cart to manage the sub-total in this specific circustance.
so I find in /catalog/controller/checkout/cart.php the this method:
$this->cart->add($this->request->post['product_id'], $this->request->post['quantity'], $option);
This action is in both of the cart controller page, index and update, but where is it the "add" method?
Thanks
You can find the method in
/system/library/cart.php
Be sure to make backups before editing, as its a core file