News:

Looking for documentation? Take a look on our wiki

Main Menu

[SOLVED] Add to cart with Custom Field - Long loading

Started by channelsurfer, August 18, 2015, 13:22:02 PM

Previous topic - Next topic

channelsurfer

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

Studio 42

Hi,
What is your plugin ?
YOur Joomla and VM release?
On my test, your current product add to cart immediatly

Jörgen

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
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

channelsurfer

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

channelsurfer

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...


Jörgen

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
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Studio 42

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 :

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.

Jörgen

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
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Studio 42

simply this code do not work in YOURSITE\plugins\vmcustom\textinput\textinput\tmpl\default.php:
// 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 :
class plgVmCustomTextinput extends vmCustomPlugin {
Add :
static $loaded = false;
and change the code in default.php to:
// preventing 2 x load javascript
if ( plgVmCustomTextinput::$loaded === true ) return true;
plgVmCustomTextinput::$loaded = true ;
//javascript to update price


Greets,
Patrick

channelsurfer

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

Milbo

Quote from: 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:
// 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
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/