Last active
August 5, 2016 08:41
-
-
Save m5wdev/aa4908c6118cc927bfcca7ec25710901 to your computer and use it in GitHub Desktop.
How to add price for one product item column in cart page (Ubercart 3)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add Price for one item in Cart page Ubercart 3 | |
* Autor: http://stackoverflow.com/a/11046318 | |
* [HOW TO USE] | |
* You can create additional module or add this code into your template.php, change 'YOUR_MODULE_NAME' into 'YOUR_THEME_NAME' | |
*/ | |
// Add 'Price' column in table Cart | |
function YOUR_MODULE_NAME_form_uc_cart_view_form_alter(&$form, &$form_state) { | |
$form['items']['#columns']['remove']['weight'] = 0; | |
$form['items']['#columns']['total']['weight'] = 5; | |
$form['items']['#columns']['qty']['weight'] = 4; | |
$form['items']['#columns']['price'] = array( | |
'cell' => t('Price'), | |
'weight' => 3, | |
); | |
} | |
// Get one product sell price and add into 'Price' column cells | |
function YOUR_MODULE_NAME_tapir_table_alter(&$table, $table_id) { | |
if ($table_id == 'uc_cart_view_table') { | |
foreach (element_children($table) as $key) { | |
if (!empty($table['#parameters'][1][$key]['nid'])) { | |
$node = node_load($table['#parameters'][1][$key]['nid']['#value']); | |
$table[$key]['price'] = array( | |
'#markup' => theme('uc_product_price',array('element' => array('#value' => $node->sell_price))), | |
); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment