VirtueMart Forum

VirtueMart 2 + 3 => Virtuemart Development and bug reports => Topic started by: channelsurfer on August 18, 2015, 13:22:02 pm

Title: [SOLVED] Add to cart with Custom Field - Long loading
Post by: channelsurfer on August 18, 2015, 13:22:02 pm
Dear all,

Maybe someone have the same problem. I add a custom field to have the possibility that the customer can add the name of the people which will attend the training.
Everything works fine. But if i add a name it needs up to 10 seconds to add the product to the cart. If i leave the custom field empty, the product is added immediately.

Here is the link: http://www.rhychi.com/buchen.html

Any idea?

Best regards,
channelsurfer
Title: Re: Add to cart with Custom Field - Long loading till product is added to the cart
Post by: Studio 42 on August 18, 2015, 17:40:44 pm
Hi,
What is your plugin ?
YOur Joomla and VM release?
On my test, your current product add to cart immediatly
Title: Re: Add to cart with Custom Field - Long loading till product is added to the cart
Post by: Jörgen on August 18, 2015, 18:00:21 pm
Hello I beg to differ

I tested the site today and found long loading times when I put text into the boxes. Not 10 seconds but 3-4 seconds, otherwise they loaded at once.
Is there some complicated tests that are done on text before adding to the database? Or does a nullstring not get handled and updated in the database?
Anyway I can clearly see the difference.

regards

Jörgen @ Kreativ Fotografi
Title: Re: Add to cart with Custom Field - Long loading till product is added to the cart
Post by: channelsurfer on August 18, 2015, 18:10:28 pm
Hi,

Thanks for your reply!

Wired... For me the product only adds immediatly when i leave the custom field empty or if i add the same name as before and add the product again.

Plugin: VP One Page Checkout (also the latest Version)
Joolma: 3.4.3
VM: 3.0.9
Title: Re: Add to cart with Custom Field - Long loading till product is added to the cart
Post by: channelsurfer on August 18, 2015, 18:13:01 pm
Hey Jörgen,

Thanks for testing. I have no idea why.  :(

The strange thing is, that if you delete the product from the cart and add it with the same name again it works fine. no loading time...

Title: Re: Add to cart with Custom Field - Long loading till product is added to the cart
Post by: Jörgen on August 18, 2015, 18:16:26 pm
Hello

That is easier to understand, local cache end saved data makes it easier to load what You just have loaded before. This does not come as a surprise.
What I find strange is that there is a difference between filled and not filled in field.
 
regards

Jörgen @ Kreativ Fotografi
Title: Re: Add to cart with Custom Field - Long loading till product is added to the cart
Post by: Studio 42 on August 18, 2015, 18:21:10 pm
The text input core javascript is bugged!
The ajax is called 16 time when you press a key in category view.
press F12 > check XHR tab when you press a key

Simply check your HTML code :

Code: [Select]
var test = function($) {
jQuery(".vmcustom-textinput").keyup(function() {
formProduct = jQuery(this).parents("form.product");
virtuemart_product_id = formProduct.find('input[name="virtuemart_product_id[]"]').val();
Virtuemart.setproducttype(formProduct,virtuemart_product_id);
});
};
16 time added.
Title: Re: Add to cart with Custom Field - Long loading till product is added to the cart
Post by: Jörgen on August 18, 2015, 18:26:05 pm
Great work

But shouldn´t this have been done and finished before putting the product in the cart?
Once updated only one time saved in the database ? Or am I wrong, if it gets saved one time for each keystroke then I can understand why the delay :)

regards

Jörgen @ Kreativ Fotografi
Title: Re: Add to cart with Custom Field - Long loading till product is added to the cart
Post by: Studio 42 on August 18, 2015, 18:27:37 pm
simply this code do not work in YOURSITE\plugins\vmcustom\textinput\textinput\tmpl\default.php:
Code: [Select]
// preventing 2 x load javascript
static $textinputjs;
if ($textinputjs) return true;
$textinputjs = true ;
//javascript to update price
YOu need to add a vlue in file YOURSITE\plugins\vmcustom\textinput\textinput.php
after :
Code: [Select]
class plgVmCustomTextinput extends vmCustomPlugin {Add :
Code: [Select]
static $loaded = false;and change the code in default.php to:
Code: [Select]
// preventing 2 x load javascript
if ( plgVmCustomTextinput::$loaded === true ) return true;
plgVmCustomTextinput::$loaded = true ;
//javascript to update price

Greets,
Patrick
Title: Re: Add to cart with Custom Field - Long loading till product is added to the cart
Post by: channelsurfer on August 18, 2015, 19:46:50 pm
Hey Patrick,

That works great... Thank you so much for your help... You are the man!!!

Wish you a nice evening.

All the best,
Elvis
Title: Re: [SOLVED] Add to cart with Custom Field - Long loading
Post by: Milbo on August 24, 2015, 20:52:18 pm
simply this code do not work in YOURSITE\plugins\vmcustom\textinput\textinput\tmpl\default.php:
Code: [Select]
// preventing 2 x load javascript
static $textinputjs;
if ($textinputjs) return true;
$textinputjs = true ;
//javascript to update price

I replace it by the new vmJsApi, which prevents problems like that