Hello,

How could one pass any cck fields of a node/product into cart template?
Adding usual

print $node->field_sklad_stav[0]['value'];

does not work.

Thank you

Comments

stewart.adam’s picture

I haven't double checked this, but I believe you'll need to implement hook_cart_item() to load the additional item data you desire into the cart item structure, then modify your template file (copy it from the 'templates' folder into your theme folder) and output the additional fields.

loparr’s picture

I created a simple custom module using hook_cart_item


function instore_cart_item($op, &$item) {
  switch ($op) {
    case 'load':
   $node = node_load($item->nid);
   $item->instore = $node->field_instore[0]['value']; 

And try to display the values using a template file for cart like this


print $item['instore'] 

So far I am getting no results.

loparr’s picture

Anybody knows how to accomplish this? Thank you
I would reeeally appreciate if someone could help me with this. I managed to show custom ckk field inside cart page with a custom module

function uc_cartdetails_form_alter(&$form, $form_state, $form_id) {


    if ($form_id == 'uc_cart_view_form' || 'uc-cart-checkout-form') {

   $form['items']['#columns']['cckfield'] = array('cell' => 'cckfield', 'weight' => 3);
  // $form['items']['#columns']['colname'] = array('cell' => 'colname', 'weight' => 4);

    // let's show the data
    foreach ($form['items'] as $key => $item) {
  if (is_numeric($key)) {
if (isset($form['items'][$key]['nid'])) {
  $node = node_load($form['items'][$key]['nid']['#value']);
          $form['items'][$key]['colname'] = array('#type' => 'value', '#value' => $node->cckfield[0]['value'], '#theme' => 'uc_cart_view_price');
		//  $form['items'][$key]['colname'] = array('#type' => 'value', '#value' => $node->cckfield[0]['value'], '#theme' => 'uc_cart_view_price');
		 
        }
      }
    }
    }
}

but not inside cart block. Where could be the problem?

loparr’s picture

Issue summary: View changes

edit