/**
* Overriding theme_uc_cart_block_content() to hide
* TOTAL from Wholesalers
*
* Theme the shopping cart block content.
*/
function phptemplate_uc_cart_block_content() {
global $user;
// Disabled until we figure out if this is actually screwing up caching. -RS
//if (!$user->uid && variable_get('cache', 0) !== 0) {
// return t('<a href="!url">View</a> your shopping cart.', array('!url' => url('cart')));
//}
if (variable_get('uc_cart_show_help_text', FALSE)) {
$output = '<span class="cart-help-text">'
. variable_get('uc_cart_help_text', t('Click title to display cart contents.'))
.'</span>';
}
$output .= '<div id="block-cart-contents">';
$items = uc_cart_get_contents();
$item_count = 0;
if (!empty($items)) {
$output .= '<table class="cart-block-table">'
.'<tbody class="cart-block-tbody">';
foreach ($items as $item) {
$display_item = module_invoke($item->module, 'cart_display', $item);
if (!empty($display_item)) {
$output .= '<tr class="cart-block-item"><td class="cart-block-item-qty">'. $display_item['qty']['#default_value'] .'x</td>'
.'<td class="cart-block-item-title">'. $display_item['title']['#value'] .'</td>'
.'<td class="cart-block-item-price">'. uc_currency_format($display_item['#total']) .'</td></tr>';
if ($display_item['options']['#value']) {
$output .= '<tr><td colspan="3">'. $display_item['options']['#value'] .'</td></tr>';
}
}
$total += ($item->price) * $item->qty;
$item_count += $item->qty;
}
$output .= '</tbody></table>';
}
else {
$output .= '<p>'. t('There are no products in your shopping cart.') .'</p>';
}
$output .= '</div>';
$item_text = format_plural($item_count, '@count Item', '@count Items');
$view = ''. l(t('View cart'), 'cart', array('rel' => 'nofollow')) .'';
if (variable_get('uc_checkout_enabled', TRUE)) {
$checkout = ' '. l(t('CHECKOUT'), 'cart', array('rel' => 'nofollow')) .'';
}
$uc_cart_path = base_path() . drupal_get_path('module', 'uc_cart');
$arrow_up_image = $uc_cart_path .'/images/bullet-arrow-up.gif';
// do not show total to wholesale users
if (in_array('Wholesale', $user->roles)) {
$output .= '<ul id="shopDeetsList">'
.'<li>BASKET ITEMS: '
. str_replace('ITEMS', '', strtoupper($item_text)) . '</li>';
} else {
$output .= '<ul id="shopDeetsList">'
.'<li>BASKET ITEMS: '
. str_replace('ITEMS', '', strtoupper($item_text)) . '</li><li>'
//.'<span class="block-cart-title-bar cart-block-toggle" id="block-cart-title-bar-arrow"><img id="block-cart-title-arrow" src="'. $arrow_up_image .'" alt="[]" title="'. t('Expand cart block.') .'" /></span>' . '</li><li>'
.'<strong>'. t('TOTAL:') .'</strong> '. uc_currency_format($total) .'</li>';
}
if ($item_count >= 0) {
//$output .= '<li>'. $checkout .'</li><li>'. $view .'</li>';
if($user->uid != 0){
$output .= '<li>'. $checkout .'</li><li class="last"><a href="/logout">SIGN-OUT</a></li>';
}
else{
$output .= '<li>'. $checkout .'</li><li class="last"><a href="/user">SIGN-IN</a></li>';
}
}
$output .= '</ul>';
return $output;
}
/**
* Overriding theme_uc_cart_view_form() to hide
* prices from Wholesalers
*
* Theme the shopping cart block content.
*/
function phptemplate_uc_cart_view_form($form) {
drupal_add_css(drupal_get_path('module', 'uc_cart') .'/uc_cart.css');
$output = '<div id="cart-form-products">'
. tapir_get_table('uc_cart_view_table', $form) .'</div>';
if (($page = variable_get('uc_continue_shopping_url', '')) != '<none>') {
if (variable_get('uc_continue_shopping_type', 'link') == 'link') {
$output .= '<div id="cart-form-buttons"><div id="continue-shopping-link">'
. l(variable_get('uc_continue_shopping_text', t('Continue shopping')), $page) .'</div>'
. drupal_render($form) .'</div>';
}
else {
$button = drupal_render($form['continue_shopping']);
$output .= '<div id="cart-form-buttons"><div id="update-checkout-buttons">'
. drupal_render($form) .'</div><div id="continue-shopping-button">'
. $button .'</div></div>';
}
}
else {
$output .= '<div id="cart-form-buttons">'. drupal_render($form) .'</div>';
}
return $output;
}
/**
* Theme the checkout review order page.
*
* @param $help
* A string containing the review order page help message.
* @param $panes
* An associative array for each checkout pane that has information to add to
* the review page. The key is the pane's title and the value is either the
* data returned for that pane or an array of returned data.
* @param $form
* The HTML version of the form that by default includes the 'Back' and
* 'Submit order' buttons at the bottom of the review page.
* @return
* A string of HTML for the page contents.
* @ingroup themeable
*/
function phptemplate_uc_cart_checkout_review($help, $panes, $form) {
drupal_add_css(drupal_get_path('module', 'uc_cart') .'/uc_cart.css');
$output = '<div>'. check_markup(variable_get('uc_checkout_review_instructions', uc_get_message('review_instructions')), variable_get('uc_checkout_review_instructions_format', 3), FALSE)
.'</div><table class="order-review-table">';
foreach ($panes as $title => $data) {
$output .= '<tr class="pane-title-row"><td colspan="2">'. $title
.'</td></tr>';
if (is_array($data)) {
foreach ($data as $row) {
if (is_array($row)) {
if (isset($row['border'])) {
$border = ' class="row-border-'. $row['border'] .'"';
}
else {
$border = '';
}
$output .= '<tr valign="top"'. $border .'><td class="title-col" '
.'nowrap>'. $row['title'] .':</td><td class="data-col">'
. $row['data'] .'</td></tr>';
}
else {
$output .= '<tr valign="top"><td colspan="2">'. $row .'</td></tr>';
}
}
}
else {
$output .= '<tr valign="top"><td colspan="2">'. $data .'</td></tr>';
}
}
$output .= '<tr class="review-button-row"><td colspan="2">'. $form
.'</td></tr></table>';
return $output;
}
/*
* Checkout page pane theming
*/
function phptemplate_uc_cart_checkout_form($form) {
drupal_add_css(drupal_get_path('module', 'uc_cart') .'/uc_cart.css');
$output = '<div>'. check_markup(variable_get('uc_checkout_instructions', ''), variable_get('uc_checkout_instructions_format', 3), FALSE) .'</div>';
if (arg(1) == 'checkout2') {
foreach (element_children($form['panes']) as $pane_id) {
$output .= drupal_render($form['panes'][$pane_id]);
}
}
else {
foreach (element_children($form['panes']) as $pane_id) {
if (function_exists(($func = _checkout_pane_data($pane_id, 'callback')))) {
$result = $func('theme', $form['panes'][$pane_id], NULL);
if (!empty($result)) {
$output .= $result;
$form['panes'][$pane_id] = array();
}
else {
$output .= drupal_render($form['panes'][$pane_id]);
}
}
else {
$output .= drupal_render($form['panes'][$pane_id]);
}
}
}
$output .= '<div id="checkout-form-bottom">'. drupal_render($form) .'</div>';
$output .= '<div class="clearfix"></div>';
return $output;
}
/*
* Cart pane in the checkout
*/
function phptemplate_cart_review_table($show_subtotal = TRUE) {
$items = uc_cart_get_contents();
$subtotal = 0;
$output = '<table class="cart-review" id="checkout-product-table" width="100%"><thead>'
.'<tr class="first odd">'
// add picture to table head
.'<th class="first picture"></th>'
.'<th class="products">'. t('Products')
.'</th><th class="qty">'. t('Quantity')
.'</th><th class="unit">'. t('Unit')
.'</th><th class="last price">'. t('Total')
.'</th>'
.'</tr></thead><tbody>';
$row = 1;
for ($i = 0; $i < count($items); $i++) {
$item = $items[$i];
$rows = array();
foreach ($item->options as $option) {
$rows[] = t('@attribute: @option', array('@attribute' => $option['attribute'], '@option' => $option['name']));
}
$desc = check_plain($item->title) . theme('item_list', $rows, NULL, 'ul', array('class' => 'cart-options'));
$total = ($item->qty) ? $item->qty * $item->price : $item->price;
$subtotal += $total;
$qty = ($item->qty) ? $item->qty : '';
$tr_class = ($i % 2 == 0) ? 'even' : 'odd';
if ($show_subtotal && $i == count($items)) {
$tr_class .= ' last';
}
$output .= '<tr class="'. $tr_class .'">'
// we add in the picture
. '<td class="picture">'
. uc_product_get_picture($item->nid, 'cart')
. '</td>'
// end
.'<td class="products">'
. $desc .'</td>'
. '<td class="qty">'
. t('!qtyx', array('!qty' => $qty)) .'</td>'
. '<td class="unit">'. uc_currency_format($item->price)
. '</td>'
. '<td class="unit">'. uc_currency_format($total)
. '</td>'
. '</tr>';
}
if ($show_subtotal) {
$tr_class = ($tr_class == 'even') ? 'odd' : 'even';
// re-jig this for theming:
$output .= '<tr class="'. $tr_class .' last">'
.'<td colspan="3" class="subtotal-spacer"> </td>'
.'<td class="subtotal-text">'
.'<strong>'. t('Total:') .'</strong>'
.'</td>'
.'<td class="subtotal">'
. uc_currency_format($subtotal) .'</td></tr>';
}
$output .= '</tbody></table>';
return $output;
}
// Theme the delivery/billing address forms in tables.
function phptemplate_address_pane($form) {
$req = '<span class="form-required">*</span>';
if (isset($form['copy_address'])) {
$output = drupal_render($form['copy_address']);
}
// show the billing address message (taken from credit card pane) here
if ($form['#attributes']['id'] == 'billing-pane') {
$output .= '<div class="billing-address-message">' . variable_get('uc_credit_policy', '') . '</div>';
}
$output .= '<div class="address-pane-table"><table>';
foreach (element_children($form) as $field) {
if (substr($field, 0, 9) == 'delivery_' || substr($field, 0, 8) == 'billing_') {
$title = $form[$field]['#title'] .':';
unset($form[$field]['#title']);
if (substr($field, -7) == 'street1') {
$title = uc_get_field_name('street') .':';
}
elseif (substr($field, -7) == 'street2') {
$title = ' ';
}
// we added field name as a class
$output .= '<tr><td class="field-label '.substr($field, -7).'">';
if ($form[$field]['#required']) {
$output .= $req;
}
$output .= $title .'</td><td>'. drupal_render($form[$field]) .'</td></tr>';
}
}
$output .= '</table></div>';
foreach (element_children($form) as $element) {
$output .= drupal_render($form[$element]);
}
return $output;
}
// Themes the form to be in a compact table.
// This is the credit card pane if you are using a payment gateway.
function phptemplate_uc_payment_method_credit_form($form) {
// Comment out this function to just straight display the form.
$form['cc_number']['#title'] = '';
$form['cc_start_month']['#title'] = '';
$form['cc_start_year']['#title'] = '';
$form['cc_exp_month']['#title'] = '';
$form['cc_exp_year']['#title'] = '';
$form['cc_issue']['#title'] = '';
if (arg(1) == 'checkout') {
$path = base_path() . drupal_get_path('module', 'uc_credit');
$output = '<table class="inline-pane-table" cellpadding="2">';
// we don't want this here - we want it up with the billing address pane
//if (strlen($form['cc_policy']) > 0) {
// added a class here for theming the warning message
//$output .= '<tr><td colspan="2" class="billing-message">'. variable_get('uc_credit_policy', '')
// .'</td></tr>';
//}
if (variable_get('uc_credit_type_enabled', FALSE)) {
$form['cc_type']['#title'] = '';
$output .= '<tr><td class="field-label">'. t('Card Type:') .'</td><td>'
. drupal_render($form['cc_type']) .'</td></tr>';
}
if (variable_get('uc_credit_owner_enabled', FALSE)) {
$form['cc_owner']['#title'] = '';
$output .= '<tr><td class="field-label">'. t('Card Owner:') .'</td><td>'
. drupal_render($form['cc_owner']) .'</td></tr>';
}
$output .= '<tr><td class="field-label">'. t('Card Number:') .'</td><td>'
. drupal_render($form['cc_number']) .'</td></tr>';
if (variable_get('uc_credit_start_enabled', FALSE)) {
$output .= '<tr><td class="field-label">'. t('Start Date:') .'</td><td>'
. drupal_render($form['cc_start_month']) .' '. drupal_render($form['cc_start_year'])
.' '. t('(if present)') .'</td></tr>';
}
$output .= '<tr><td class="field-label">'. t('Expiration Date:') .'</td><td>'
. drupal_render($form['cc_exp_month']) .' '
. drupal_render($form['cc_exp_year']) .'</td></tr>';
if (variable_get('uc_credit_issue_enabled', FALSE)) {
$output .= '<tr><td class="field-label">'. t('Issue Number:') .'</td><td>'
. drupal_render($form['cc_issue']) .' '. t('(if present)').'</td></tr>';
}
if (variable_get('uc_credit_cvv_enabled', TRUE)) {
$form['cc_cvv']['#title'] = '';
$output .= '<tr><td class="field-label">'. t('CVV:') .'</td><td>'. drupal_render($form['cc_cvv'])
.' <img src="'. $path .'/images/info.png" onclick="cvv_info_popup();" style="cursor: pointer; position: relative; top: 3px;"> <a style="cursor: pointer; font-weight: normal;" onclick="cvv_info_popup();">'
. t("What's the CVV?") .'</a></td></tr>';
}
if (variable_get('uc_credit_bank_enabled', FALSE)) {
$form['cc_bank']['#title'] = '';
$output .= '<tr><td class="field-label">'. t('Issuing Bank:') .'</td><td>'
. drupal_render($form['cc_bank']) .'</td></tr>';
}
$output .= '</table>';
}
else {
$output = '<table class="order-edit-table"><tbody style="border-top: 0px;">';
if (variable_get('uc_credit_type_enabled', FALSE)) {
$form['cc_type']['#title'] = '';
$output .= '<tr><td class="oet-label">'. t('Card Type:') .'</td><td>'
. drupal_render($form['cc_type']) .'</td></tr>';
}
if (variable_get('uc_credit_owner_enabled', FALSE)) {
$form['cc_owner']['#title'] = '';
$output .= '<tr><td class="oet-label">'. t('Card Owner:') .'</td><td>'
. drupal_render($form['cc_owner']) .'</td></tr>';
}
$output .= '<tr><td class="oet-label">'. t('Card Number:') .'</td><td>'
. drupal_render($form['cc_number']) .'</td></tr>';
$output .= '<tr><td class="oet-label">'. t('Expiration Date:') .'</td><td>'
. drupal_render($form['cc_exp_month']) .' '
. drupal_render($form['cc_exp_year']) .'</td></tr>';
if (variable_get('uc_credit_cvv_enabled', TRUE)) {
$form['cc_cvv']['#title'] = '';
$output .= '<tr><td class="oet-label">'. t('CVV:') .'</td><td>'
. drupal_render($form['cc_cvv']) .'</td></tr>';
}
if (variable_get('uc_credit_bank_enabled', FALSE)) {
$form['cc_bank']['#title'] = '';
$output .= '<tr><td class="oet-label">'. t('Issuing Bank:') .'</td><td>'
. drupal_render($form['cc_bank']) .'</td></tr>';
}
$output .= '</td></tr></tbody></table>';
}
return $output;
}