Forums / Templates, Stylesheets, Page Layout / Adding Field to Checkout

Adding Field to Checkout

Views: 31,098

Results 81 to 84 of 84
11 Jan 2016, 7:11 AM
#81
vandiermen avatar

vandiermen

Totally Zenned

Join Date:
Feb 2007
Posts:
518
Plugin Contributions:
1

Adding Field to Checkout

Sorry to bump this post. The first page instructions work great for 1.5.4. I now have working field order_frequent_code populated from checkout_shipping page.
I am trying to echo order_frequent_code in admin/orders.php page, I have tried number of different things but missing something. Maybe someone has the done it already.

Here is my 1.5.4 modified code attempt:

admin/order.php

  <?php echo $order->fields['frequent_code']; ?> <?php echo zen_date_long($order->info['frequent_code']); ?> <?php echo zen_draw_input_field('frequent_code'); ?> d </td>

==============================================================

<?php// create search filter  $search = '';  if (isset($_GET['search']) && zen_not_null($_GET['search'])) {    $search_distinct = ' ';    $keywords = zen_db_input(zen_db_prepare_input($_GET['search']));    $search = " and (o.customers_city like '%" . $keywords . "%' or o.customers_postcode like '%" . $keywords . "%' or o.date_purchased like '%" . $keywords . "%' or o.billing_name like '%" . $keywords . "%' or o.billing_company like '%" . $keywords . "%' or o.billing_street_address like '%" . $keywords . "%' or o.delivery_city like '%" . $keywords . "%' or o.delivery_postcode like '%" . $keywords . "%' or o.delivery_name like '%" . $keywords . "%' or o.delivery_company like '%" . $keywords . "%' or o.delivery_street_address like '%" . $keywords . "%' or o.billing_city like '%" . $keywords . "%' or o.billing_postcode like '%" . $keywords . "%' or o.customers_email_address like '%" . $keywords . "%' or o.customers_name like '%" . $keywords . "%' or o.customers_company like '%" . $keywords . "%' or o.customers_street_address  like '%" . $keywords . "%' or o.order_frequent_code  like '%"  . $keywords . "%' or o.customers_telephone like '%" . $keywords . "%' or o.ip_address  like '%" . $keywords . "%')";    $new_table = '';//    $new_fields = ", o.customers_company, o.customers_email_address, o.customers_street_address, o.delivery_company, o.delivery_name, o.delivery_street_address, o.billing_company, o.billing_name, o.billing_street_address, o.payment_module_code, o.shipping_module_code, o.order_frequent_code, o.ip_address ";  }} // eof: search orders or orders_products    $new_fields = ", o.customers_company, o.customers_email_address, o.customers_street_address, o.delivery_company, o.delivery_name, o.delivery_street_address, o.billing_company, o.billing_name, o.billing_street_address, o.payment_module_code, o.shipping_module_code, o.order_frequent_code, o.ip_address ";?>

OR ============================================

<?php    if (isset($_GET['cID'])) {      $cID = zen_db_prepare_input($_GET['cID']);      $orders_query_raw =   "select o.orders_id, o.customers_id, o.customers_name, o.payment_method, o.frequent_code, o.shipping_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total" .                            $new_fields . "                            from (" . TABLE_ORDERS_STATUS . " s, " .                            TABLE_ORDERS . " o " .                            $new_table . ")                            left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id and ot.class = 'ot_total') " . "                            where o.customers_id = '" . (int)$cID . "' and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$_SESSION['languages_id'] . "' order by orders_id DESC";
//echo '<BR><BR>I SEE A: ' . $orders_query_raw . '<BR><BR>';
    } elseif ($_GET['status'] != '') {      $status = zen_db_prepare_input($_GET['status']);      $orders_query_raw = "select o.orders_id, o.customers_id, o.customers_name, o.payment_method, o.frequent_code, o.shipping_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total" .                          $new_fields . "                          from (" . TABLE_ORDERS_STATUS . " s, " .                          TABLE_ORDERS . " o " .                          $new_table . ")                          left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id and ot.class = 'ot_total') " . "                          where o.orders_status = s.orders_status_id and s.language_id = '" . (int)$_SESSION['languages_id'] . "' and s.orders_status_id = '" . (int)$status . "'  " .                          $search . " order by o.orders_id DESC";
//echo '<BR><BR>I SEE B: ' . $orders_query_raw . '<BR><BR>';
    } else {      $orders_query_raw = "select " . $search_distinct . " o.orders_id, o.customers_id, o.customers_name, o.payment_method, o.frequent_code, o.shipping_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total" .                          $new_fields . "                          from (" . TABLE_ORDERS_STATUS . " s, " .                          TABLE_ORDERS . " o " .                          $new_table . ")                          left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id and ot.class = 'ot_total') " . "                          where (o.orders_status = s.orders_status_id and s.language_id = '" . (int)$_SESSION['languages_id'] . "')  " .                          $search . " order by o.orders_id DESC";
//echo '<BR><BR>I SEE C: ' . $orders_query_raw . '<BR><BR>';
    }
// Split Page

admin/includes/classes/order.php
line 62

       
      $this->info = array('currency' => $order->fields['currency'],                          'currency_value' => $order->fields['currency_value'],                          'payment_method' => $order->fields['payment_method'],                          'payment_module_code' => $order->fields['payment_module_code'],                          'shipping_method' => $order->fields['shipping_method'],                          'shipping_module_code' => $order->fields['shipping_module_code'],                          'coupon_code' => $order->fields['coupon_code'],                          'cc_type' => $order->fields['cc_type'],                          'cc_owner' => $order->fields['cc_owner'],                          'cc_number' => $order->fields['cc_number'],                          'cc_cvv' => $order->fields['cc_cvv'],                          'cc_expires' => $order->fields['cc_expires'],                          'date_purchased' => $order->fields['date_purchased'],                          'orders_status' => $order->fields['orders_status'],                          'total' => $order->fields['order_total'],                          'tax' => $order->fields['order_tax'],                          'last_modified' => $order->fields['last_modified'],                          'ip_address' => $order->fields['ip_address'],                         'order_frequent_code' => $order->fields['frequent_code']);

line 23

    function query($order_id) {      global $db;      $order = $db->Execute("select cc_cvv, customers_name, customers_company, customers_street_address,                                    customers_suburb, customers_city, customers_postcode, customers_id,                                    customers_state, customers_country, customers_telephone,                                    customers_email_address, customers_address_format_id, delivery_name,                                    delivery_company, delivery_street_address, delivery_suburb,                                    delivery_city, delivery_postcode, delivery_state, delivery_country,                                    delivery_address_format_id, billing_name, billing_company,                                    billing_street_address, billing_suburb, billing_city, billing_postcode,                                    billing_state, billing_country, billing_address_format_id,                                    coupon_code, payment_method, payment_module_code, shipping_method, shipping_module_code,                                    cc_type, cc_owner, cc_number, cc_expires, currency,                                    currency_value, date_purchased, orders_status, last_modified,                                    order_total, order_tax, order_frequent_code, ip_address                             from " . TABLE_ORDERS . "                             where orders_id = '" . (int)$order_id . "'");
11 Jan 2016, 3:43 PM
#82
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Adding Field to Checkout

Did you also do:

example:

$order_query = "... order_flight_airline, order_flight_num, order_flight_arv, order_flight_dep, ...

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

22 Jan 2016, 5:06 AM
#83
vandiermen avatar

vandiermen

Totally Zenned

Join Date:
Feb 2007
Posts:
518
Plugin Contributions:
1

Re: Adding Field to Checkout

cpannek and others:

Need to add fields onto the checkout payment page
......
it wont populate in my database.

Kuroi gave answer on page 1. To clarify:

EDIT
includes/modules/pages/checkout_confirmation/header_php.php

FIND
$_SESSION['comments'] = $_POST['comments'];

ADD under it

if (isset($_SESSION['frequent_code'])) {$frequent_code = $_SESSION['frequent_code'];}

if (zen_not_null($_POST['frequent_code'])) {$_SESSION['frequent_code'] = zen_db_prepare_input($_POST['frequent_code']);}
$frequent_code = $_SESSION['frequent_code'];

ALSO I added the same code to includes/modules/pages/checkout_payment/header_php.php (but probably just need to add it to checkout_confirmation/header_php.php)

EDIT
includes/modules/pages/checkout_payment/header_php.php

ADD

if (isset($_SESSION['frequent_code'])) {$frequent_code = $_SESSION['frequent_code'];}

if (zen_not_null($_POST['frequent_code'])) {$_SESSION['frequent_code'] = zen_db_prepare_input($_POST['frequent_code']);}
$frequent_code = $_SESSION['frequent_code'];


UNDER $_SESSION['comments'] = $_POST['comments'];

22 Jan 2016, 7:53 AM
#84
vandiermen avatar

vandiermen

Totally Zenned

Join Date:
Feb 2007
Posts:
518
Plugin Contributions:
1

Re: Adding Field to Checkout

vandiermen:

I am trying to echo order_frequent_code in admin/orders.php page, I have tried number of different things but missing something. Maybe someone has the done it already.

Thanks.
Here is working code:

EDIT
admin/includes/classes/order.php

CHANGE

                                    currency_value, date_purchased, orders_status, last_modified,
                                    order_total, order_tax, ip_address

TO

 currency_value, date_purchased, orders_status, last_modified,
                                    order_total, order_tax, order_frequent_code, ip_address

(under function query($order_id) {)

FIND

$order->fields['last_modified'],
                          'ip_address' => $order->fields['ip_address'],

CHANGE TO

$order->fields['last_modified'],                          'ip_address' => $order->fields['ip_address'],                          'order_frequent_code' => $order->fields['order_frequent_code'],

EDIT
admin/order.php

ADD

          <tr>                <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '5'); ?></td>              </tr>              <tr>                <td class="main"><strong><?php echo "Orders Frequent Code:"; ?></strong></td>                <td class="main"><?php echo $order->info['order_frequent_code']; ?></td>              </tr>

where you want the code to be echoed

I was so close the first time...