Hello
Please, follow to https://algolplus.freshdesk.com/support/solutions/articles/25000016635-add-calculated-field-for-order-
use metakey “current_day” and this PHP code.
add_filter('woe_get_order_value_current_day',function ($value, $order,$fieldname) {
return current_time("Y-m-d");
},10,3);
To color cells — add this PHP code to section “Misc Settings” too.
add_action( 'woe_xls_print_footer', function ($objXls,$formatter) {
$sheet = $objXls->getActiveSheet();
$sheet->getStyle('A1')->applyFromArray(
array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('rgb' => 'FF0000')
)
)
);
}, 10, 2);
thanks, Alex
Thread Starter
imborx
(@imborx)
Hi Alex @algolplus, I really appreciate your help. Your answer was super fast!
1) Done!
2) About colloring cells, that works… but if I tried to color more than 1 cell using “$sheet->getStyle(‘A1, B1, F1,’)” I get an error. So I dont know how can I set different cells.
3) Is there any way to control the witdh of the columns? Now seems to be autofit with the column title, but I want some rows narrower. On the left what I want and on the right what I have: https://i.gyazo.com/e095a3d0894530a6b1f482038a7a1774.png
4) How can I set a conditional for a column? For example: if billing_state “X, Y or Z” show 48, if billing_state “A, B or C” show 14.
Thanks!
-
This reply was modified 6 years, 3 months ago by
imborx.
2) try this version
add_action( 'woe_xls_print_footer', function ($objXls,$formatter) {
$sheet = $objXls->getActiveSheet();
$sheet->getStyle('A1')->applyFromArray(
array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'color' => array('rgb' => 'FF0000')
)
)
);
$sheet ->duplicateStyle($sheet->getStyle('A1'), 'B1');
$sheet ->duplicateStyle($sheet->getStyle('A1'), 'F1');
}, 10, 2);
3) is ” Auto column width” ON in section XLS?
4) Please, follow to https://algolplus.freshdesk.com/support/solutions/articles/25000016635-add-calculated-field-for-order-
use metakey “state_calc” and this PHP code.
add_filter('woe_get_order_value_state_calc',function ($value, $order,$fieldname) {
$state = $order->get_billing_state();
if($state == "A" OR $state == "B" OR $state=="C" ) $value = 14;
if($state == "X" OR $state == "Y" OR $state=="Z" ) $value = 48;
return $value;
},10,3);
Thread Starter
imborx
(@imborx)
Hi again @algolplus
2) Awesome!
3) That works perfect
4) I follow the steps and unfortunately it didn’t print anything in that column. I’m 100% sure that I’ve add the meta_key correctly adding “state_calc”. You can check that somethings it’s not working at all: https://i.gyazo.com/448347b5b8fdaf1a324d92f647633f4c.png
5) Is there any way to show in a column just the private order notes?
Thanks again, your plugin it’s amazing!!
4) I think you should use state abbreviations.
for example, “PM” instead of “Baleares”.
see mapping at page https://github.com/woocommerce/woocommerce/blob/master/i18n/states.php#L296
5) Please, follow to https://algolplus.freshdesk.com/support/solutions/articles/25000016635-add-calculated-field-for-order-
use metakey “priv_notes” and this PHP code.
add_filter('woe_get_order_value_priv_notes',function ($value, $order,$fieldname) {
$notes = wc_get_order_notes( array( 'order_id' => $order->get_id() ) );
$comments = array();
if ( $notes ) {
foreach ( $notes as $note ) {
if( $note->customer_note OR 'system' === $note->added_by)
continue;
$comments[] = $note->content;
}
}
return implode( "\n", $comments );
},10,3);
Thread Starter
imborx
(@imborx)
Hi @algolplus,
4) & 6) Works pretty well, really appreciate your help 🙂
Finally, is there any way to have different group saved fields to export? I would like to have some of them to export manually and some of them automatically.
Thanks!
you have to use tab “Profiles”, but it’s pro feature 😉