Author Topic: [SOLVED] Add to cart with Custom Field - Long loading  (Read 1573 times)

channelsurfer

  • Beginner
  • *
  • Posts: 14
[SOLVED] Add to cart with Custom Field - Long loading
« 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

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3955
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Hi,
What is your plugin ?
YOur Joomla and VM release?
On my test, your current product add to cart immediatly

Jörgen

  • Global Moderator
  • Full Member
  • *
  • Posts: 2280
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
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.8
Virtuemart 3.4.x
Olympiantheme Hera (customized)

channelsurfer

  • Beginner
  • *
  • Posts: 14
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

  • Beginner
  • *
  • Posts: 14
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

  • Global Moderator
  • Full Member
  • *
  • Posts: 2280
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
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.8
Virtuemart 3.4.x
Olympiantheme Hera (customized)

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3955
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
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.

Jörgen

  • Global Moderator
  • Full Member
  • *
  • Posts: 2280
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
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.8
Virtuemart 3.4.x
Olympiantheme Hera (customized)

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3955
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
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

channelsurfer

  • Beginner
  • *
  • Posts: 14
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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9853
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: [SOLVED] Add to cart with Custom Field - Long loading
« Reply #10 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
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/