News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Add to cart by SKU

Started by postsingular, March 05, 2015, 17:20:23 PM

Previous topic - Next topic

postsingular

I'm using VM 2.6.6

I'm trying to build a very simple form with only one input field, where users can enter an SKU and add that product to the cart.

I found a piece of code (see below) that works with virtuemart_product_id, but not with an SKU.

Could someone help me modify this code to accept SKUs instead of product IDs?

<form method="post">
<span class="addtocart-button">
<input class="addtocart-button" title="Add to Cart" type="submit" name="addtocart" value="Add to Cart" /> </span>
<input type="hidden" name="quantity[]" value="1" />
<input type="hidden" name="option" value="com_virtuemart" />
<input type="hidden" name="view" value="cart" />
<input type="hidden" name="task" value="add" />
<input name="virtuemart_product_id[]" value="1" />
</form>

GJC Web Design

2.6.6 is old and unsafe

but back to your question

I guess hack the add() function in components\com_virtuemart\helpers\cart.php to detect when a sku is sent and then look up the corresponding product_id and continue
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Milbo

then I would also change the table product.php and set the SKU unique as the slug.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/