Drupal: Add product field on cart for Ubercart

×

Error message

  • Deprecated function: Return type of DatabaseStatementBase::execute($args = [], $options = []) should either be compatible with PDOStatement::execute(?array $params = null): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in require_once() (line 2244 of /var/www/html/drupaldeveloper.in/includes/database/database.inc).
  • Deprecated function: Return type of DatabaseStatementEmpty::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in require_once() (line 2346 of /var/www/html/drupaldeveloper.in/includes/database/database.inc).
  • Deprecated function: Return type of DatabaseStatementEmpty::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in require_once() (line 2346 of /var/www/html/drupaldeveloper.in/includes/database/database.inc).
  • Deprecated function: Return type of DatabaseStatementEmpty::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in require_once() (line 2346 of /var/www/html/drupaldeveloper.in/includes/database/database.inc).
  • Deprecated function: Return type of DatabaseStatementEmpty::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in require_once() (line 2346 of /var/www/html/drupaldeveloper.in/includes/database/database.inc).
  • Deprecated function: Return type of DatabaseStatementEmpty::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in require_once() (line 2346 of /var/www/html/drupaldeveloper.in/includes/database/database.inc).

This CodeLet let you display product field on cart page.

Display Product field on cart table
CodeLet: 

<?php
/**
* Implementation of hook_form_alter
*
* @param $form
* @param $form_state
* @param $form_id
* @saru1683
*/
function custom_uc_tax_remove_form_alter(&$form, &$form_state, $form_id) {

switch($form_id) {
case 'uc_cart_view_form':

// Adding Product field column
$form['items']['#columns']['Edition'] = array('cell' => t('Edition'), 'weight' => 2.5);

for($i=0; $i < count($form['items']); $i++) {
if(isset($form['items'][$i]['nid'])) {

// Loading the node so we can retrieve the information we need.
$product = node_load($form['items'][$i]['nid']['#value']);

$ss__edition = $product->field_product_fieldl['und'][0]['value'];

// Adding the 'Product field' to the cart form, that is in the user's cart.
$form['items'][$i]['Edition'] = array('#markup' => $ss__edition);

}
}
break;
}
}
?>

Compatibility: 
Is CodeLet useful?: 
Drupal: Add product field on cart for Ubercart | Drupal Developer

Error

The website encountered an unexpected error. Please try again later.