News:

Support the VirtueMart project and become a member

Main Menu

Possible to add custom field to checkout process?

Started by rustle, February 15, 2012, 18:32:27 PM

Previous topic - Next topic

rustle

Hi guys I am looking to add a custom, mandatory dropdown selector field to the check out process.. Is this possible?
If so could somebody point me in the right direction.

VM 2.0.1e
Joomla 1.73

joseweb

I really need this too, did you solve it somehow ?

PRO


Axiom

Hi all, yes, this is something I'm hunting for too, and have found other questions about it, but no real solution... The Shopper Fields, how they are implemented and the ease to get to them are exactly what I need - but don't quite fit the bill.

At the cart, we have the "change bill to / ship to", product information and then the customer comments field, and this is a good place to add more questions,
but there's no "clickable" solution for this like Shopper Fields is set up for - we have to hack the core.
Then we have Shopper Fields, which allow for entry in Maintenance, Shipping or Registration, but again, although this is EXACTLY what I want,  you can't create a NEW section (or button to one on the cart front page), so all the information my client needs doesn't appear easily.
In essence we want to remove the forms she's been using and place the required questions into the checkout process of virtuemart.
We then have a record of the purchase, the type of purchase, the ability to review history, and of course each order placed gets treated as specified by their client.

My client, sells custom health products made to order. Sometimes they sell a single item (or bulk), others have multiple items custom mixed.
With Virtuemart, I can have the web user choose all the items in the quantities they need... so so far so good. But then they have no way to enter the rest of the information required.
See my client needs to know if her clients are ordering a simple bulk stock order or if it's a custom mix of stuff for their clients.
I tried to do this by replacing the comments box, but that's insane for 20 or so questions/drop boxes etc and when I tried to do this in the "ship to" area it all went pie eyed really fast, and if I stick the fields elsewhere, they dont apply to the order at hand, just the client's account.

SO I need to be able to add shopper fields to the Cart front page... the page with the "add comment box"

Now The functionality is already there in the Virtuemart Core - we have shopper fields, we have the admin area to create and modify them, and we have the button to get the bill to / ship to areas appears on the cart front page, and the physical injection of the custom comment box at the bottom....

Yes, I can go hack the snot out of the core and add the fields where that custom note box is, but with each update I'd be rebuilding it....

So if we cannot add fields and such to that front cart page, then at least give us the option to have a button appear to a custom page like the "ship to"

I simply do not have the PHP skills to pull off a mod to the core that would somehow link optional shopper fields to the cart front page, but I'm willing to have a go if someone on the team would work with me and we could add it to the next update for all to enjoy?


Axiom

No one up for the challenge?

In 2.5, We have everything we need - just sitting right there, and if I had someone working with me I'm sure we could come up with a solution - I just don't have the PHP knowledge to attack it all on my own...

There's a multitude of posts and queries regarding this...  like how amazon has a three page checkout system where you can edit this, add that... surely since the shopper fields exist it's not too daunting to have a go?

AndyGaskell

I know this is an old topic, but no one noted a solution.

I've been working on something using template overrides and JQuery to add fields, and have them submitted as part of the comment box.  Happy to share this if it'd be handy to anyone, if so, just reply here and let me know.

Andy
Software Systems: Open For Business
Aberdeen's Leading Open Source Web Systems Provider

rodfarrell

Andy I'm definitely interested.  Any chance that this can be different fro each user group?

AndyGaskell

Quote from: rodfarrell on February 04, 2013, 23:13:50 PM
Andy I'm definitely interested.  Any chance that this can be different fro each user group?

I'm not sure, it may be possible, but with my solution, the fields are shown on the cart page, and at that point the user might not be logged in, so would be the default user group
Software Systems: Open For Business
Aberdeen's Leading Open Source Web Systems Provider

nata_r10

Hello everyone!! Seems that it made it!!

I inserted the custom fields in the edit address options. In VM 2.0.20 the file to edit is:

/components/com_virtuemart/views/user/tmpl/edit_address.php

First you need to call some classes to be able to call the products information:

<?php
if (!class_exists( 'VmModel' )) require(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_virtuemart'.DS.'helpers'.DS.'vmmodel.php');
    if (!class_exists( 'VmConfig' )) require(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart'.DS.'helpers'.DS.'config.php');
      if(!class_exists('VirtueMartCart')) require(JPATH_VM_SITE.DS.'helpers'.DS.'cart.php');
      $cart = VirtueMartCart::getCart(false);

?>


Second: You create the cart product array, here is going to be kept all the product info:


<?php
foreach($cart->products as $pkey =>$prow ) {
      $productModel = VmModel::getModel('product');
      $productxx = $productModel->getProduct($prow->virtuemart_product_id);
   }
?>

Third: You create a mini check out form, with the custom fields: As we have the product array now is easier to call the customFields. And also you need to include all the hidden inputs of the form and finally call the submit button.


<form method="post" class="product js-recalculate" action="<?php echo JRoute::_ ('index.php'); ?>">
            <input name="quantity" type="hidden" value="1" />   
   <?php
   if (!empty($productxx->customfieldsCart)) {
      ?>
      <div class="product-fields">
         <?php foreach ($productxx->customfieldsCart as $field) { ?>
         <div class="product-field product-field-type-<?php echo $field->field_type ?>">
            <span class="product-fields-title-wrapper"><span class="product-fields-title"><strong><?php echo JText::_ ($field->custom_title) ?></strong></span>
            <?php if ($field->custom_tip) {
            echo JHTML::tooltip ($field->custom_tip, JText::_ ($field->custom_title), 'tooltip.png');
         } ?></span>
            <span class="product-field-display"><?php echo $field->display ?></span>

            <span class="product-field-desc"><?php echo $field->custom_field_desc ?></span>
         </div><br/>
         <?php
      }
         ?>
      </div>
      <?php
   }
   
   ?>
   
    <input type="hidden" class="pname" value="<?php echo htmlentities($productxx->product_name, ENT_QUOTES, 'utf-8') ?>"/>
    <input type="hidden" name="option" value="com_virtuemart"/>
    <input type="hidden" name="view" value="cart"/>
    <noscript><input type="hidden" name="task" value="add"/></noscript>
    <input type="hidden" name="virtuemart_product_id[]" value="<?php echo $productxx->virtuemart_product_id ?>"/>
    <?php echo shopFunctionsF::getAddToCartButton ($productxx->orderable); ?>
   
    </form>

That´s it! In the frontend, when you enter to edit address the custom fields will be displayed.

If you want to include de custom fields somewhere else I guess you only need to check that the classes you call wont cause any errors.

Eso sería, no hablo inglés nativo así que si me equivoqué en algo, disculparán!

NR

publicidad3

I understand this is a bit of an old post, but its very current for me. i have managed to do to a degree, what i need in my site, this post has been most usefull, but now i have an issue, this one delivers but with an issue, it does not update the information on the item but adds another item to the cart.

what i need is to change this:

<?php echo shopFunctionsF::getAddToCartButton ($productxx->orderable); ?>

to an update button similar to the quantity update, but that only updates the information on the product. in this case, change the size and or color of such item. Any ideas how i can do this?


[attachment cleanup by admin]