News:

Support the VirtueMart project and become a member

Main Menu

Show custom fields in cart that can be selected and be mandatory

Started by its4yougr, March 18, 2017, 19:39:09 PM

Previous topic - Next topic

its4yougr

Hello to all
I am using VirtueMart 3.0.18 on Joomla! 3.6.5.
I use here https://www.leathercareland.com the One Page Checkout for Virtuemart here http://vmonepage.com  and it works fine. It just changes the cart layout to be responsive and fits my needs.

A. Selected Custom Fields in Cart
The problem that I have is that I cannot display the custom fields into the cart so that the buyer can make his choice or change a choice that  he made. I think this is because of VM3 limitation where you cannot get the selectable list of custom field options in the cart. If you have selected i.e. the color or size in the product page then here at the cart it just displays the text of your selections. You don't get the drop down list of the custom field choices like you do on the product page. I have set Layout Position -> addtocart, Cart Attribute -> Yes, Cart Input-> Yes to all my custom fields. I see that into the file default_left.php (One Page Checkout file) around line 230 there is the code :

<?php
if (!empty(
$prow->customfields)) 

 $customfiledstext $this->customfieldsModel->CustomsFieldCartDisplay($prow);
 $customfiledstext str_replace("<br />"""$customfiledstext);
 echo str_replace('<span''<span class="opg-text-small" '$customfiledstext);

?>


which displays your selection, if you had made any at the product details page. If you added to cart the product, that has custom fields, from category page, which means that you didn't make a selection of custom field value, at the cart you get COM_VIRTUEMART_PLEASE_CHOOSE. There is no dropdown list in to the cart.

Please add to cart the following item w/o making any selection for color : ​https://leathercareland.com/en/proionta/peripoiisi-dermatos/krema-gyalismatos-ypodimaton-high-gloss-shoe-cream-pate-de-luxe-2-detail which has a custom field SAPHIRE Colors and value COM_VIRTUEMART_PLEASE_CHOOSE. That is what is displayed into the cart.

I tried adding the same code that exists into the default.php file into the productdetails directory that is :

echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'normal'));

But this doesn't display anything also.

Could you advise me on what to do / try?

Is there any documentation on how to use Sublayouts outside of VM or at Cart? I found this (https://docs.virtuemart.net/tutorials/templating-layouts/199-sublayouts.html) but didn't help me at all...

B. Mandatory / Required Custom Fields in Cart.

Now, if I can achieve to get the drop down selection in cart (point A) I would like to make those custom fields required / mandatory if possible. The products in shop that have custom fields have to have a value for custom field. Whoever shops must select a value for color and / or size. I have found this https://forum.virtuemart.net/index.php?topic=100172.0 buty is talking about child variants and not custom fields. There is also a hack including java script that marks with red the fields and pops up message that one has to make a selection but this is in the product page.... 


Thank you in advance
Κατασκευή Ιστοσελίδων Θεσσαλονίκη - http://www.its4you.gr/
WebDesign Internet Marketing - http://www.webdesign-internetmarketing.com/

PRO

why not "show custom fields in category view"

It is an option.


&& echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'normal'));

is the wrong "position"

Custom fields cart is   position addtocart

its4yougr

I thank you very much for your reply.....
Yes you are right
   echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'normal'));
Is wrong for my case
echo shopFunctionsF::renderVmSubLayout('customfields',array('product'=>$this->product,'position'=>'addtocart'));
is the correct one ! ! !
Sorry about that..
I did the proposed change but still it doesn't work again.....
I think that I cannot call sublayouts under cart or any plugin inside or outside of VM

Yes the option of showing the Custom Fields into the category page is a good one for a general case where you just have colors or sizes that are few and are not selected form a color chart like here the Saphire and Tarrago colors..... The visitor needs to see a big color chart to select the color code from about 120 color codes.

Thanks a lot
Κατασκευή Ιστοσελίδων Θεσσαλονίκη - http://www.its4you.gr/
WebDesign Internet Marketing - http://www.webdesign-internetmarketing.com/

Milbo

Changing variants in the cart would mean, that storing the cart checks for updating CartProductData and that is just not written.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

PRO

Quote from: its4yougr on March 19, 2017, 19:28:35 PM

Yes the option of showing the Custom Fields into the category page is a good one for a general case where you just have colors or sizes that are few and are not selected form a color chart like here the Saphire and Tarrago colors..... The visitor needs to see a big color chart to select the color code from about 120 color codes.


In your situation it is NOT smart to allow addtocart from category.
You should want the customer to go to the product page, and MAKE SURE, they know what they are getting.

add to cart from category should only be used for simple products.

its4yougr

Hello to all and thanks for your prompt replies
   In this e-shop the customer needs to have a kind of quick checkout.... Meaning that he wants to provide a quick and easy way of putting items in the basket and pay for them. On the other hand, the way it works now is, when he gets orders that color or size (for insoles) values are missing he needs to call the customer and get the order corrected.
The best way would have been to put the items in the basket and be able to checkout only if the necessary custom fields are selected and that means mandatory fields. Right?

Quote from: Milbo on March 20, 2017, 09:22:31 AM
Changing variants in the cart would mean, that storing the cart checks for updating CartProductData and that is just not written.

Thanks Milbo for your reply.... That means that Virtuemart is not able to do that. Right?

I am not a coder but the way I was thinking of this is if the custom field is mandatory and there is no selection made when the products is added to the cart, at the cart, there should be a warning and a link where the product details page is called on a pop up with an Update Cart button and not an Add to Cart button where the product gets re-added to the basket with the updated custom field values..... Is that my imaginary fiction or what......

I probably need to hire a programmer to do that and I don't know if this will be safe from hacks for the e-shop.

I thank you very much.... If there is some other idea I will be glad to post it here. Is there a possibility for including that into any future update?
Thanks
Κατασκευή Ιστοσελίδων Θεσσαλονίκη - http://www.its4you.gr/
WebDesign Internet Marketing - http://www.webdesign-internetmarketing.com/

GJC Web Design

I have made variants mandatory (I mean standard VM custom fields) by using JS in the templates

If u try here for example:  https://www.soesterpapierdiscounter.nl/pbm/hygienedisposables

you can't add to cart without choosing a custom (Is there a core way of making them mandatory?)

both cat view and details are done in the template over rides -- probably not the prettiest code but works

p.m me if interested

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

its4yougr

Hi GJC Web Design
  I thank you for your reply.
Yes this would have been a solution but in my case one needs to see the color chart (which is a big one) in order to select the color code from the dropdown of the custom field. There is no way to be able to display the custom fields + the color chart like is displayed at the product page.
The best solution in my case but for others too would have been to show the custom fields at the cart and be able to make them mandatory.

Thank you
Κατασκευή Ιστοσελίδων Θεσσαλονίκη - http://www.its4you.gr/
WebDesign Internet Marketing - http://www.webdesign-internetmarketing.com/

GJC Web Design

but surely you need to think about how people shop --

they come to your site looking for leather care products after a Google search or what ever

they go to Bags and Shoes..  now just remove the add to cart buttons and have only a product details button

then they go to the detail, see the colour chart and enforce there the selection

No one is going to say.. "WHAT! .. an extra click!!!!  I'm in such a hurry I will now go and search for another site that allows me to add to cart without colour charts and help."

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Milbo

I wrote this also

for the membership. Check here http://extensions.virtuemart.net/support. You cannot enter the domain in the browse view. It would spam the browseview. The browseview is not loading the position of the download by host customfield. The product itself is set by the customfield to "unorderable".

When you click the product http://extensions.virtuemart.net/support/virtuemart-supporter-membership-detail , then you see that the addtocart button is not working. And the special trick is, that it is also not working, when the js is disabled. An input field appears, because it uses another position, which we added by layout override. The JS enables the button, when a correct domain is entered. You could even just enter the URL of your store (with http and all that) and you get a corrected domain. But also here, I do not allow that people change the domain in the cart later. It is too complex at the moment and usually not necessary. When they want to change the domain in the cart later, they have to delete the product at the moment.

So yes, you can also write me to get something like that, http://extensions.virtuemart.net/ticket

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

its4yougr

Thanks again for looking into that and replying....

   Milbo your solution is really more complicated but I think this is how it needs to be done in your case. On the other hand, I think I found a simpler solution that can be applied to all of virtuemart installations with products that have custom fields or not.
Here is goes:
   At the category page, display the add to cart button on all products but if the product has custom field values to be selected then when someone clicks on the add to cart button display in pop up the product page with a message that custom fields need to be selected. There, at the product page, after the visitor makes his selections he can add it to the cart using the Add to Cart button on product page. If the product doesn't have any custom field values to be selected then it just displays the normal message "The product has been added to the cart". This way the visitor can see the color chart, in my case or other info related to the custom fields and make the correct choices only for products that require it.
Now to check if the product has custom fields :

$position = 'addtocart';
if(!empty($product->customfieldsSorted[$position])){
                   (WHAT CODE CAN I PUT HERE?????) //[b]To Open Product Details Page in Pop Up and Display a Message at the top "You need to select size or color"[/b]
                  } else {
                  (WHAT CODE CAN I PUT HERE?????) //[b]To Open the Pop Up "Your Product has been added to the cart" ---> Go to Cart ---> Continue Shopping[/b]
                  }

For the second part : <?php echo shopFunctionsF::renderVmSubLayout('addtocart',array('product'=>$product,'rowHeights'=>$rowsHeight[$row])); ?>
might work but for the first step how could I open the product details page on a pop up?
The above code can be added either to the products_horizon.php and/or products.php files under sublayouts directory.
See I am not a coder and I cannot follow the VMSubLayouts at all..... I cannot write the code.... Could you help?

Thanks again
I think the above would solve many problems with custom fields and add to cart...
Thanks
Κατασκευή Ιστοσελίδων Θεσσαλονίκη - http://www.its4you.gr/
WebDesign Internet Marketing - http://www.webdesign-internetmarketing.com/

AH

Use a quikview type plugin

QuoteAt the category page, display the add to cart button on all products but if the product has custom field values to be selected then when someone clicks on the add to cart button display in pop up the product page with a message that custom fields need to be selected. There, at the product page, after the visitor makes his selections he can add it to the cart using the Add to Cart button on product page.

This is exactly the behaviour of very early version of VM  - VM1
Regards
A

Joomla 4.4.5
php 8.1