News:

Looking for documentation? Take a look on our wiki

Main Menu

Adding multiple products to cart with one button

Started by webgobe, April 28, 2021, 18:11:08 PM

Previous topic - Next topic

webgobe

I need to build a module which dynamically lists products (based on multiple criteria - done) which can be added to the cart with a single click. Searched a lot in the forums, but none of solutions found seems to work for me. I am using latest VM on latest Joomla.
TIA
Like a fine wine... Good from the start and getting better over time.

pinochico

www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

webgobe

Sorry, but your product does not know what I need. I need a relatively simple functionality for an existing module which lists the products giving to a (pretty complex) criteria. I need to add to that module the option to add the products listed to the cart, with one click. Not one by one - that is working already. The key needed trick is the use of a single add-to-cart button. Something like there:
http://vm3.sm-planet.net/catproduct/new-checkbox-example-detail
You see that below the main product the related products are listed with checkboxes. And after selecting the ones you need, you can add them with ONE CLICK to the cart.
Like a fine wine... Good from the start and getting better over time.

Studio 42

Why not using catproduct ?
I implement a javascript in the category view for a customer so you can select each product.
https://www.willys.be/index.php/fr/component/virtuemart/189/body-smal-stuf-mirror.html?Itemid=333
If you do not need to show the checkbox you can use a javascript list of product ids (or hidden input) and send to the cart using ajax, display the cart popup then update the cart module

webgobe

I was considering it, because is close  in some regards to what the client wants, but it is overkill. He wanted an extremely simple interface to select products related to the main/master products and some extra functionalities CatProduct does not provide, as dynamic discounts, like if the associated products are bought together with the master product, to have a discounted price. And more: if they are put and removed independently from cart, the prices to change accordingly.
Let me give you an example, let's see the main product is a hat, the associated products are a pair of gloves and a bag. First part is simple, the gloves and the bag should be shown in the hat's page, and ALL 3 (or ideally the master product and the selected associated products) to have a single add to cart button. This part is what catproduct can do. (BTW, the interface to set this up is over-complicated in the client's opinion, but let's not take that in consideration). Let's say, if these are bought together the associated products have a discounted price.
The trick here is, that the discount should be applied or not to the products in the cart regardless of how they get there. So, if I am adding only the master to the cart, and later I am adding one of associated products - and not with that infamous single add to cart button, the discount should be applied.
More, if later I remove the master product from the cart, the associated product's price should be re-adjusted to show the non discounted base price. Well, this is the part which catproduct can't handle. And the component I built can do all that (and more). This is why catproduct does not fit the bill there.
BTW, it is a terrific product - just simply can't do what I am required to provide.
Like a fine wine... Good from the start and getting better over time.

pinochico

Quotethe associated product's price should be re-adjusted to show the non discounted base price

Nice custom work :)
Catproduct we use on two shops (yes we know, the development is stoped from 2019), so I'm waiting for your solutions.
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

ermes

See if you are interested in a solution like the one we created for the https://wwwnumeritermoadesivi.it site with the lower bar "Create your box".

webgobe

Will post it as done. In mean time I found what I did wrong - I have too many VM related ongoing developments, one of those conflicted with the new module and I was thinking that this module is the culprit ;).
Thanks for your time trying to help me!
Like a fine wine... Good from the start and getting better over time.

pinochico

QuoteWill post it as done. In mean time I found what I did wrong - I have too many VM related ongoing developments, one of those conflicted with the new module and I was thinking that this module is the culprit ;).
Thanks for your time trying to help me!

Closed without a description of the solution for others?
It may not be right, but it can be an inspiration for the future.
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

webgobe

Promised, that when all will be done, will post the solution there. The solution was inspired by this thread: https://forum.virtuemart.net/index.php?topic=136440.0
Like a fine wine... Good from the start and getting better over time.

pinochico

Yep, you are right

the finally solutions will be between catproduct, product builder and awo coupon.

We spend most of our time doing the same steps - purchasing an approximate product for the solution and then reprogramming it to suit the end client's intentions.

But we also have a responsibility and we have to tell the client his ideas.
Not all its requirements and ideas are correct for an ecommerce solution, then we refuse to develop and integrate this solution.
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

webgobe

BTW, the promised solution I was looking for:
<form method="post" action="index.php">
  <?php foreach($products as $id){
$rel=ModVMCDHelper::getProduct($id); ?>

  <div class="vmcd-module"><?php echo $rel->product_name?><br />
    <input type="hidden" name="virtuemart_product_id[]" value="<?php echo $id?>">
    <label>Quantity</label>
    <input type="checkbox" name="quantity[]" value="1">
  </div>
  <?php ?>
  <br />
  <input type="hidden" name="option" value="com_virtuemart" />
  <input type="hidden" name="view" value="cart" />
  <input type="hidden" name="task" value="add" />
  <input type="submit" name="addtocart" class="addtocart-button" value="Add to Cart" title="Add to Cart" />
</form>

Some explanations:
$products is an array holding the product ID's,
ModVMCDHelper::getProduct($id) is a helper function wich fetches the product details - product name in the example.
If checkboxes shown are checked, the products are added in the cart. You can use standard text input boxes, in which case you can enter the quantities desired, if 0 is added, the respective product isn't added to the cart.
But this is the essence of the trick. Tested and works on VM 2+.
Like a fine wine... Good from the start and getting better over time.

pinochico

QuoteModVMCDHelper::getProduct($id)

I think similiar function exist in core VM, or not?
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

Studio 42

The problem is not to render the list, but to apply discounts
Cat product can do it, my plugin extra products too.
But none can calculate discounts.
The only solution i know is to use a virtuemart coupon plugin

balai