News:

Support the VirtueMart project and become a member

Main Menu

Searching in store invalidates any custom code written?

Started by mailblade, February 17, 2018, 09:09:47 AM

Previous topic - Next topic

mailblade

My products are listed in table format. In the last column of the table, is the "Addtocart" class.

Now, depending on certain values for the products, there is some code which will determine whether the "Addtocart-button" should be disabled or not, for the specific item. (It checks if the $cartItem['quantity'] is == the $max_balance for the current product. $max_balance is a custom variable I created)

Now, it's not a lot of code, just a simple "if" statement.

When the balance for the product in the cart is the SAME as the one defined in the category page listing, the addtocart-button is disabled. Meaning they can't order anymore. (I have multiple stores and each one has a product balance, not all the same)

HOWEVER, when I search for the product SKU, then enter max allowed "balance" into the cart (not stock quantity, $max_balance is custom defined value) and reload the page, it's not disabling the button.

Simple explanation:

1.Two stores and two products
2. Stock Quantity for both stores is 50
3. Store 1 has 30 as "$max_balance" (customfield), Store 2 has 20 as $max_balance
4. If you are in user group Store 1, you can not order more than 30 of the product. It alerts when you try and order 31, and if you order 30 on the dot it checks the $cartItem['quantity'] and checks the $max_balance, it then determines if you can order more. (it's working)
5. When I search for an item, these features disappear. Almost as if the code disappears. I think it's because there's a different URL when you search.

Is there any way I can edit the search module?

Studio 42

You request need a core hack, override system plugin to use own class or you have to develop a customfield plugin, if you have only some product that use this values