Custom Fields not saving to order

If you are runnig Joomla 3.x and Virtuemart 3.x please post to this forum your questions or support tickets about One Page Checkout

Custom Fields not saving to order

Postby stuartcottrell » Fri Sep 25, 2015 2:38 pm

Hi!

Joomla 3.4.4
Virtuemart 3.0.10
Rupostel OPC2 2.0.296.090915

So I've created a custom template and several new custom fields under the Ship To. I've added in JS validation to the Ship To fields, as for some reason there is no way of doing it through the plugin? Thats all fine.

When the checkout passes to payment and the order is logged on Virtuemart, the custom fields show up in the back office, but without values and on the invoicing they don't show up at all... Screenshots attached - any ideas?

I understand that the information isn't getting passed to the database for whatever reason, but I believe the plugin should be doing that right? Any help you can give (the more detailed the better) would be really appreciated.

Screen-Shot-2015-09-25-at-13.26.47.jpg
Front End
Screen-Shot-2015-09-25-at-13.26.47.jpg (95.51 KiB) Viewed 10550 times


Screen-Shot-2015-09-25-at-13.32.16.jpg
Back End 1
Screen-Shot-2015-09-25-at-13.32.16.jpg (103.36 KiB) Viewed 10550 times


Screen-Shot-2015-09-25-at-13.34.21.jpg
Back End 2
Screen-Shot-2015-09-25-at-13.34.21.jpg (107.16 KiB) Viewed 10550 times
stuartcottrell
 
Posts: 3
Joined: Fri Sep 25, 2015 2:24 pm

Re: Custom Fields not saving to order

Postby admin » Fri Sep 25, 2015 5:07 pm

hello, the most important aspect on the ship to address is that it's complete ignored if there is no checkbox (or other means) which tells OPC to use it.

OPC supports many ways of working with the ST (ship to address):
- it can be disabled
- it can be always enabled (flower shop example)
- it can be optional with default status closed (default)
- it can be optional with default status opened (default)

let me know what is your desired logic for the ST address.

the validation of the ST address:
- by default OPC does not validate the ST fields because there is no config to tell VM that the same field is "obligatory for BT but not mandatory for ST", and for most uses the ST address can be further filled from BT address
- you can enable "obligatory ST fields" at OPC's Shopper fields tab (just make sure that those fields which are required for the ST address are checked)

Furthermore this can be combined with :
- custom rendered fields (they are not rendered by opc at all, you can render them anywhere incide the checkout form)
- cart (alias for order-only) fields (they are always emptied upon the checkout visit and they do not get stored with user data, only are stored (optionally) in order data, or just processed by a payment (such as a SSN which is not stored anywhere, just processed by klarna, birth date or other sensible data which are required, but cannot be stored are other examples)


i can help you configure this as there may be further variations of the above logic:
- a logged in user may always need to write a new ship to address (usually B2B or a gift shop)
- a logged in user with thousands of the Ship To addresses which are loaded over ajax (B2B)

i am available for more help during the business days usually from 11 to 18 GMT time.

best regards, stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm

Re: Custom Fields not saving to order

Postby stuartcottrell » Sat Sep 26, 2015 9:13 am

Thanks for your reply!

I need to get the ship to custom fields to save to the database and order please!
stuartcottrell
 
Posts: 3
Joined: Fri Sep 25, 2015 2:24 pm

Re: Custom Fields not saving to order

Postby admin » Mon Sep 28, 2015 12:34 pm

hello stuart, pls write me on your live chat and i will check all your configs for this.
best regards, stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm

Re: Custom Fields not saving to order

Postby admin » Mon Sep 28, 2015 3:16 pm

hello stuart, to summarize what i did on your site:

- i made all the special Event fields to be part of the BT
- i added support for delimiter usage within your theme by:
-- copying config.xml from the original clean_simple2 theme + delimiter_start + delimiter_end php theme files
-- i enabled and reordered the delimiters so they display properly
-- i disabled the ST section within OPC since the ST should be used for the address and it could cause problems when procesed by payment/shippng plugins when it's missing some of the basic address fields

i modified your invoice pdf + email teamplates so they render the bottom section at the Ship to section. They get cut at "company2" field and these are the modified files:

\templates\YOUR JOOMLA TEMPLATE\html\com_virtuemart\invoice\mail_html_shopperaddresses.php
Code: Select all
<?php
/**
*
* Layout for the order email
* shows the chosen adresses of the shopper
* taken from the stored order
*
* @package   VirtueMart
* @subpackage Order
* @author Max Milbers,   Valerie Isaksen
*
* @link http://www.virtuemart.net
* @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
?>
<table class="html-email" cellspacing="0" cellpadding="0" border="0" width="100%">  <tr  >
   <th width="50%">
       <?php echo vmText::_('COM_VIRTUEMART_USER_FORM_BILLTO_LBL'); ?>
   </th>
   <th width="50%" >
       <?php echo vmText::_('Event Details'); ?>
   </th>
    </tr>
    <tr>
   <td valign="top" width="50%">

       <?php

       foreach ($this->userfields['fields'] as $field) {
      if (!empty($field['value'])) {
         
         if ($field['name'] === 'company2')
         {
            if (empty($event_html))
            $event_html = ' ';
         }
         
         
      if (!empty($field['value'])) {
         if (!empty($event_html))
         {
            ob_start();
             ?><!-- span class="titles"><?php echo $field['title'] ?></span -->
              <span class="values vm2<?php echo '-' . $field['name'] ?>" ><?php echo $field['value'] ?></span>
         <?php if ($field['name'] != 'title' and $field['name'] != 'first_name' and $field['name'] != 'middle_name' and $field['name'] != 'zip') { ?>
             <br class="clear" />
             <?php
            
         }
         $z = ob_get_clean();
            $event_html .= $z;
         
         }
         else
         {
         
          ?><!-- span class="titles"><?php echo $field['title'] ?></span -->
              <span class="values vm2<?php echo '-' . $field['name'] ?>" ><?php echo $field['value'] ?></span>
         <?php if ($field['name'] != 'title' and $field['name'] != 'first_name' and $field['name'] != 'middle_name' and $field['name'] != 'zip') { ?>
             <br class="clear" />
             <?php
         }
         }
      }
         
         
         
          }
      
       }
       ?>

   </td>
   <td valign="top" width="50%">
       <?php
      
      if (!empty($event_html))
      {
         echo $event_html;
      }
      if (!empty($this->shipmentfields['fields']))
       foreach ($this->shipmentfields['fields'] as $field) {

      if (!empty($field['value'])) {
             ?><!-- span class="titles"><?php echo $field['title'] ?></span -->
             <span class="values vm2<?php echo '-' . $field['name'] ?>" ><?php echo $field['value'] ?></span>
             <?php if ($field['name'] != 'title' and $field['name'] != 'first_name' and $field['name'] != 'middle_name' and $field['name'] != 'zip') { ?>
                 <br class="clear" />
            <?php
             }
         }
       }

       ?>
   </td>
    </tr>
</table>




and invoice file:
\templates\YOUR JOOMLA TEMPLATE\html\com_virtuemart\invoice\invoice_order.php

Code: Select all
<?php
/**
*
* Order detail view
*
* @package   VirtueMart
* @subpackage Orders
* @author Oscar van Eijk, Valerie Isaksen
* @link http://www.virtuemart.net
* @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* @version $Id: details_order.php 5341 2012-01-31 07:43:24Z alatak $
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
?>

<?php
if ($this->doctype == 'invoice') {
  if ($this->invoiceNumber) { ?>
<h1><?php echo vmText::_('COM_VIRTUEMART_INVOICE').' '.$this->invoiceNumber; ?> </h1>
<?php }
} elseif ($this->doctype == 'deliverynote') { ?>
<h1><?php echo vmText::_('COM_VIRTUEMART_DELIVERYNOTE'); ?> </h1>
<?php } elseif ($this->doctype == 'confirmation') { ?>
<h1><?php echo vmText::_('COM_VIRTUEMART_CONFIRMATION'); ?> </h1>

<?php } ?>

<table width="100%" cellspacing="0" cellpadding="0" border="0">
   <?php if ($this->invoiceNumber) { ?>
    <tr>
   <td class=""><?php echo vmText::_('COM_VIRTUEMART_INVOICE_DATE') ?></td>
   <td align="left"><?php echo vmJsApi::date($this->invoiceDate, 'LC4', true); ?></td>
    </tr>
       <?php } ?>
   <?php if (!empty($this->orderDetails['details']['BT']->delivery_date)) { ?>
      <tr>
         <td class=""><?php echo vmText::_('COM_VIRTUEMART_DELIVERY_DATE') ?></td>
         <td align="left"><?php echo $this->orderDetails['details']['BT']->delivery_date ?></td>
      </tr>
   <?php } ?>
    <tr>
   <td ><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_PO_NUMBER') ?></td>
   <td align="left"><strong>
       <?php echo $this->orderDetails['details']['BT']->order_number; ?>
      </strong>
   </td>
    </tr>

    <tr>
   <td class=""><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_PO_DATE') ?></td>
   <td align="left"><?php echo vmJsApi::date($this->orderDetails['details']['BT']->created_on, 'LC4', true); ?></td>
    </tr>
    <tr>
   <td class=""><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_PO_STATUS') ?></td>
   <td align="left"><?php echo $this->orderstatuses[$this->orderDetails['details']['BT']->order_status]; ?></td>
    </tr>
    <tr>
   <td class=""><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_SHIPMENT_LBL') ?></td>
   <td align="left"><?php
       echo $this->orderDetails['shipmentName'];
       ?></td>
    </tr>
    <tr>
   <td class=""><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_PAYMENT_LBL') ?></td>
   <td align="left"><?php echo $this->orderDetails['paymentName']; ?>
   </td>
    </tr>
<?php if ($this->orderDetails['details']['BT']->customer_note) { ?>
    <tr>
    <td><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_CUSTOMER_NOTE') ?></td>
    <td valign="top" align="left" width="50%"><?php echo $this->orderDetails['details']['BT']->customer_note; ?></td>
</tr>
<?php } ?>
<?php if ($this->doctype == 'invoice') { ?>
     <tr>
   <td class="orders-key"><strong><?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_TOTAL') ?></strong></td>
   <td class="orders-key" align="left"><strong><?php echo $this->currency->priceDisplay($this->orderDetails['details']['BT']->order_total,$this->currency); ?></strong></td>
    </tr>
<?php } ?>

    <tr>
   <td colspan="2"></td>
    </tr>
    <tr>
   <td valign="top"><strong>
       <?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_BILL_TO_LBL') ?></strong> <br/>
       <table border="0"><?php
      $event_html = '';
       foreach ($this->userfields['fields'] as $field) {
         if ($field['name'] === 'company2')
         {
            if (empty($event_html))
            $event_html = ' ';
         }
         
         
      if (!empty($field['value'])) {
         if (!empty($event_html))
         {
            $event_html .= '<tr><td class="key">' . $field['title'] . '</td>'
          . '<td>' . $field['value'] . '</td></tr>';
         }
         else
         {
         
          echo '<tr><td class="key">' . $field['title'] . '</td>'
          . '<td>' . $field['value'] . '</td></tr>';
         }
      }
       }
       ?></table>
   </td>
   <td valign="top" ><strong>
       <?php echo vmText::_('Event Details') ?></strong><br/>
       <table border="0"><?php
      
      if (!empty($event_html)) echo $event_html;
      if (!empty($this->shipmentfields['fields']))
      {
         
         ?><strong>
       <?php echo vmText::_('COM_VIRTUEMART_ORDER_PRINT_SHIP_TO_LBL') ?></strong><br/>
      <?php
       foreach ($this->shipmentfields['fields'] as $field) {
         
         
      if (!empty($field['value'])) {
          echo '<tr><td class="key">' . $field['title'] . '</td>'
          . '<td>' . $field['value'] . '</td></tr>';
      }
       }
      }
       ?></table>
   </td>
    </tr>
</table>



best regards, stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm

Re: Custom Fields not saving to order

Postby stuartcottrell » Mon Sep 28, 2015 11:24 pm

Hi Stan,

So after you had done that work for me, I moved the website across and now the fields are not being saved again on the back office? I'm not sure what the problem is or if you modified another file I'm not aware of. The database was changed slightly on the move over from test to the normal domain to preserve Virtuemart i.e. Orders/ Products/ Categories. On checking out with a Cheque/ Bank Transfer an email is sent out by the system but using the Credit/ Debit card payment method, no email is sent out. Now this is live it is a big problem for me as I don't have the information available to me that I need on the orders. Any help you can give would massively be appreciated!

Thank you in advance again!

Regards,
Stuart
stuartcottrell
 
Posts: 3
Joined: Fri Sep 25, 2015 2:24 pm

Re: Custom Fields not saving to order

Postby admin » Tue Sep 29, 2015 3:38 pm

hello Stuart, while you copied your demo site to the live site, the shopper fields usually alter the DB structure, i.e. columns within the order and userinfos tables. i checked this via phpmyadmin on your site and fixed it by visiting each of your special fields and clicking "save" in VM which created/updated the structure of your tables.

best regards, stan
admin
Site Admin
 
Posts: 2708
Joined: Wed Jan 06, 2010 11:43 pm


Return to One Page Checkout for Virtuemart 3 on Joomla 3.x