Due to the nature of my ajax style cart View cart is most likely to be skipped by people....is it feasible show this block also in the checkout page?

Comments

planctus’s picture

I did this:
i've created a file named uc_upsell_checkout_pane.inc, here is the content:

<?php
/**
 * Implementation of hook_checkout_pane().
 */
function uc_upsell_checkout_pane() {
  $panes[] = array(
    'id' => 'upsell',
    'callback' => 'uc_checkout_pane_upsell',
    'title' => t('Related products'),
    'desc' => t("Display the related products"),
    'weight' => 1,
    'process' => FALSE,
    'collapsible' => FALSE,
  );
  return $panes;
}

/**
 * Build the checkout panel
 */
function uc_checkout_pane_upsell($op, &$arg1, $arg2) {
  switch($op) {
    case 'view':
    $items = uc_cart_get_contents();
    $related = uc_upsell_resolve_associates($items); 
    $description = '';
    $contents['upsell'] = array(
    '#type' => 'markup',
    '#value' => theme('pane_upsell', $related, $items)
    );
  return array('description' => $description, 'contents' => $contents);
  }
}

Then you need to run this code, you might include include_once 'uc_upsell_checkout_pane.inc'; it in a custom module renaming file and its functions consistently.
But there's also a problem while using uc_upsell_resolve_associates(&$msg = '')
Because it checks for the 'cart' path only.
So, you might copy that function simply changing its name and changing this
if ($dpath == 'cart')
To this:
if ($dpath == 'cart' || $dpath == 'cart/checkout')

Otherwise you could do this directly in the upsell module context, but this would break your new feature after ugrading the module...
I don't know, this could also lead to a patch for the upsell_module, i just wanted to share it.
See you,
Da.

torgospizza’s picture

Thanks, I'll review this shortly.

mattcasey’s picture

subscribing