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>
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
then I would also change the table product.php and set the SKU unique as the slug.