Author Topic: Multiple plugin custom fields as cart attribute  (Read 3714 times)

Stephen Roberts

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 142
    • SundaySchool.com
Multiple plugin custom fields as cart attribute
« on: June 22, 2014, 23:45:20 pm »
Tested with:
Joomla! 2.5.22
VirtueMart 2.6.0 AND 2.6.6 (the latest)

VM 2.6.0 introduced a bug with custom fields where multiple instances of a custom field plugin as a cart attribute do not work any longer. This is breaking functionality for my plugin (DigiToll Downloads for VM) and I'm having to send my customers hacked versions of the cart helper.

Steps to reproduce the problem:

1. Start with a standard installation of Joomla! 2.5.22 and VirtueMart 2.6.6
2. Create a new custom field of type "plugin", cart attribute "yes", and select the text input plugin that ships with VM
3. Edit a product (I edited the Dress), and attach 2 instances of the text input plugin to the product.
4. On the FE, enter text in both fields and add to cart
5. You'll notice in the cart that only 1 field shows up. This behavior continues throughout the checkout

I traced the problem to /components/com_virtuemart/helpers/cart.php in the add() method. The way the new algorithm works (as of VM 2.6.0), is that it accidentally eliminates multiple instances of the same plugin from the product's attributes. My interim solution for my customers is to basically replace most of the add() method with code from the older versions of VM.

This is a critical problem for my product as it's causing all of my customers to hack VirtueMart. I look forward to having this fixed in a future release. Please ask me for any additional details!

Thanks for the great work guys!

Stephen
Sell downloadable (virtual) products in VirtueMart 2 and deliver downloads via local server, Amazon S3, and more! http://www.digitollsoftware.com

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10070
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Multiple plugin custom fields as cart attribute
« Reply #1 on: June 23, 2014, 09:49:24 am »
ehrm Stephen, the new logic IS the fix. In the old version, I could easily exchange the download.

Furthermore you can have now the customfield plugin in a list of products and it works correctly.

Or in other words. Before when you used a custom more than one time on the screen, then it could happen that the product is added with the wrong customfield to the cart.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Stephen Roberts

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 142
    • SundaySchool.com
Re: Multiple plugin custom fields as cart attribute
« Reply #2 on: June 23, 2014, 16:47:16 pm »
Using the old logic, I was able to bind each instance of the plugin to a different cart attribute. This allowed customers to attach one or more downloads to each attribute and serve up the correct files to the customer depending on what option they selected.

Even in the example I gave above, doesn't it make sense that you might want 2 text input fields on a product for various reasons? It really seems like a regression in functionality. I'd like to make sure this change has been very well thought out before I spend the time to completely rewrite my plugin to compensate.

I look forward to hearing your thoughts!
Sell downloadable (virtual) products in VirtueMart 2 and deliver downloads via local server, Amazon S3, and more! http://www.digitollsoftware.com

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10070
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Multiple plugin custom fields as cart attribute
« Reply #3 on: June 23, 2014, 23:04:10 pm »
Strange thing. I solved it abstract to exactly address the problem if more than one time the customfield is displayed. So it should also now work in category lists.

and it is completly shitty, because I did the whole thing for vm3 already by result the same, but the solution is exactly the opposite way. ;-)

in vm2 the customfields are loaded, the procduct is loaded and checked if the product has the customfield. in Vm3, the product is created and the given data (from the form) is just attached and if the product has the correct customfield it starts to process it.

So you must take a look on vm3 please. http://docs.virtuemart.net/tutorials/development/175-code-adjustments-for-virtuemart-3.html

in Vm3 the whole thing is overhauled. You can use the same customfield as often you want for one product.

Maybe you wrote a big workaround around this architecture error in vm2 (I am sorry, it was not me). But now it is solved by the core. You can use one "customprototype" as often you want for one product and you get always the correct data! and it is hacksafe. I am not sure that your system is hack proof, if you get in trouble now.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Stephen Roberts

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 142
    • SundaySchool.com
Re: Multiple plugin custom fields as cart attribute
« Reply #4 on: June 24, 2014, 06:42:32 am »
Thanks for the clarification Max. I'll do what I can to accommodate for the change.
Sell downloadable (virtual) products in VirtueMart 2 and deliver downloads via local server, Amazon S3, and more! http://www.digitollsoftware.com

mrvirtuem

  • Beginner
  • *
  • Posts: 2
Re: Multiple plugin custom fields as cart attribute
« Reply #5 on: July 28, 2014, 22:55:27 pm »
Joomla 2.5.24
VM 2.6.6

Hi Milbo, Stephen,

I have exactly the same problem. I want to use the VMcustom textinput plugin multiple times with the same product.
As it only registers the first textfield in the cart and order this is a problem.

As I understand from the thread it is still possible to use vmcustom textinput multiple times per product.
Can you clarify how to set this up in the backend it puzzles me completely.

Thanks.
MR

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10070
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Multiple plugin custom fields as cart attribute
« Reply #6 on: July 29, 2014, 11:43:57 am »
No

it was never possible in vm2, to use the same customfield prototype for the same product. Of course you could do it, but it was not working correctly. If you want in vm2 the same customfield twice, then create two times a custom prototype with the textinput and then use them.

In vm3, you can use one custom prototype as often you want at one product. That is also the reason, why in vm3 the add to cart button is native in the category view.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

mrvirtuem

  • Beginner
  • *
  • Posts: 2
Re: Multiple plugin custom fields as cart attribute
« Reply #7 on: August 05, 2014, 20:55:59 pm »
Thanks Milbo for the information.

The double prototype fields is the solution for me now.

Great info.

Thanks again.

VMR