Administrator
- Join Date:
- Sep 2009
- Location:
- Stuart, FL
- Posts:
- 14,154
- Plugin Contributions:
- 56
Post #1 by lat9
Developing a new order total which has a title similar to This Shop's Discount and found that, after placing an order, the order-total's title was being truncated in the database as This Shop (i.e. everything including/after the single-quote was being discarded).
A small change to the two :censored: order.php class files allows quotes (and other slashable characters) to be included in an order-total's title.
/YOUR_ADMIN/includes/classes/order.php (in function query):
$totals = $db->Execute("select title, text, class, value
from " . TABLE_ORDERS_TOTAL . "
where orders_id = '" . (int)$order_id . "'
order by sort_order");
while (!$totals->EOF) {
if ($totals->fields['class'] == 'ot_coupon') {
$coupon_link_query = "SELECT coupon_id
from " . TABLE_COUPONS . "
where coupon_code ='" . zen_db_input($order->fields['coupon_code']) . "'";
$coupon_link = $db->Execute($coupon_link_query);
$zc_coupon_link = '<a href="javascript:couponpopupWindow(\'' . zen_catalog_href_link(FILENAME_POPUP_COUPON_HELP, 'cID=' . $coupon_link->fields['coupon_id']) . '\')">';
}
$this->totals[] = array('title' => stripslashes (($totals->fields['class'] == 'ot_coupon' ? $zc_coupon_link . $totals->fields['title'] . '</a>' : $totals->fields['title'])), //-lat9-Strip slashes to allow quotes in totals' titles
'text' => $totals->fields['text'],
'value' => $totals->fields['value'],
'class' => $totals->fields['class']);
$totals->MoveNext();
}
and in /includes/classes/order.php. First in function query:
$totals_query = "select title, text, class
from " . TABLE_ORDERS_TOTAL . "
where orders_id = '" . (int)$order_id . "'
order by sort_order";
$totals = $db->Execute($totals_query);
while (!$totals->EOF) {
if ($totals->fields['class'] == 'ot_coupon') {
$coupon_link_query = "SELECT coupon_id
from " . TABLE_COUPONS . "
where coupon_code ='" . $order->fields['coupon_code'] . "'";
$coupon_link = $db->Execute($coupon_link_query);
$zc_coupon_link = '<a href="javascript:couponpopupWindow(\'' . zen_href_link(FILENAME_POPUP_COUPON_HELP, 'cID=' . $coupon_link->fields['coupon_id']) . '\')">';
}
$this->totals[] = array('title' => stripslashes (($totals->fields['class'] == 'ot_coupon' ? $zc_coupon_link . $totals->fields['title'] . '</a>' : $totals->fields['title'])), //-lat9-Strip added slashes for quotes in titles
'text' => $totals->fields['text'],
'class' => $totals->fields['class']);
$totals->MoveNext();
}
and then in function create:
$this->notify('NOTIFY_ORDER_DURING_CREATE_ADDED_ORDER_HEADER', array_merge(array('orders_id' => $insert_id, 'shipping_weight' => $_SESSION['cart']->weight), $sql_data_array));
for ($i=0, $n=sizeof($zf_ot_modules); $i<$n; $i++) {
$sql_data_array = array('orders_id' => $insert_id,
'title' => addslashes ($zf_ot_modules[$i]['title']), //-lat9-add slashes to allow quotes in module titles
'text' => $zf_ot_modules[$i]['text'],
'value' => (is_numeric($zf_ot_modules[$i]['value'])) ? $zf_ot_modules[$i]['value'] : '0',
'class' => $zf_ot_modules[$i]['code'],
'sort_order' => $zf_ot_modules[$i]['sort_order']);
zen_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array);
$this->notify('NOTIFY_ORDER_DURING_CREATE_ADDED_ORDERTOTAL_LINE_ITEM', $sql_data_array);
}