Χρήσιμα filters
Στο παρακάτω παράδειγμα ορίζουμε μέγιστο βάρος τα 2 κιλά εάν είναι πάνω απο 2, διαφορετικά θα πάρει το βάρος που έχει αυτόματα υπολογιστεί από τα προϊόντα
function ibeb_acs_myweight($weight){
if ($weight > 2){
$newweight = 2;
}else{
$newweight = $weight;
}
return $newweight;
}
add_filter( 'iben_acs_filter_weight_order_metabox', 'ibeb_acs_myweight' );
Εαν έχετε custom πεδίο στο checkout, πχ Κινητό και meta name είναι _billing_mobile κανένα πρόβλημα.
Σε άλλη περίπτωση εαν το custom πεδίο σας έχει διαφορετικό meta name τότε θα πρέπει να τρέξετε το παρακάτω κώδικα στο αρχείο chilld functions.php και απλά αλλάξτε το όνομα _billing_mobile με το δικό σας meta όνομα.
Η κάτω παύλα ( _ ) είναι απαραίτητη.
function ben_acs_mycustomphonefield(){
return '_billing_mobile';
}
add_filter( 'iben_acs_filter_phone2_metafield_order_metabox', 'ben_acs_mycustomphonefield' );
iben_acs_filter_comments_order_metabox
Για τα σχόλια / παρατηρήσεις του voucher
iben_acs_filter_cashdelivery_order_metabox
Για την αντικαταβολή του voucher
Σε κάποιες περιπτώσεις που χρησιμοποιείται μέθοδο πληρωμής (αντικαταβολή) από κάποιο άλλο plugin ή custom. Σε αυτή την περίπτωση το plugin δεν γνωρίζει εαν είναι αντικαταβολή και να προστεθεί αυτόματα στο πεδίο.
alg_custom_gateway_1 = Είναι το ID της μεθόδου πληρωμής
add_filter('iben_acs_filter_cashdelivery_payments_order_metabox', 'iben_acs_cash_delivery_add_alg_custom1');
function iben_acs_cash_delivery_add_alg_custom1(){
return $payments = array('alg_custom_gateway_1');
}
Σε περίπτωση που θέλετε να εκτυπώνεται ο αρ. παραγγελίας μέσα στα σχόλια του voucher θα πρέπει να χρησιμοποιήσετε την παρακάτω function
add_filter('iben_acs_filter_combine_comments_metafield_order', 'iben_acs_override_com_meta', 10, 2);
add_filter('iben_acs_filter_automatic_comments_metafield_order', 'iben_acs_override_com_meta', 10, 2);
add_filter('iben_acs_filter_comments_order_metabox', 'iben_acs_override_com_meta', 10, 2);
function iben_acs_override_com_meta($comment, $order_id){
$order = wc_get_order($order_id);
if (!is_object($order)){
return;
}
//GET ORDER COMMENTS
$comments = $order->get_customer_note();
$order_number = $order->get_order_number();
return 'Παραγγελία ID:'.$order_number.' '.$comments;
}
//works for automatic actions too
//add_filter('iben_acs_filter_automatic_comments_metafield_order', 'iben_acs_display_products_in_comments', 10, 2 );
//works for bulk creation too
//add_filter('iben_acs_filter_combine_comments_metafield_order', 'iben_acs_display_products_in_comments', 10, 2 );
add_filter('iben_acs_filter_comments_order_metabox', 'iben_acs_display_products_in_comments', 10, 2 );
function iben_acs_display_products_in_comments($comments, $order_id){
$order = wc_get_order($order_id);
if (!is_object($order)){
return;
}
$export = '';
if ($order->get_items()){
$count = count($order->get_items());
$index = 0;
foreach( $order->get_items() as $item_id => $product_item ){
$index++;
$product = $product_item->get_product();
$export .= $product->get_name().' x '.$product_item->get_quantity().($index == $count ? '': ', ');
}
}
// Εμφάνιση προιόντων μόνο
return $export;
// Εμφάνιση σχόλια πελάτη + προιόντα
// return $comments.' '.$export;
}
add_filter('iben_acs_filter_billingcode_order_metabox', 'iben_acs_filter_billing_code', 10, 2);
function iben_acs_filter_billing_code($billingcode, $order_id){
$order = wc_get_order($order_id);
if ( !is_a( $order, 'WC_Order' ) ){
return $billingcode;
}
foreach( $order->get_items() as $item_id => $product_item ){
$total_weight = 0;
foreach( $order->get_items() as $item_id => $product_item ){
$quantity = $product_item->get_quantity(); // get quantity
$product = $product_item->get_product(); // get the WC_Product object
if( $product ) {
$product_weight = $product->get_weight(); // get the product weight
$total_weight += floatval( ( $product_weight ? $product_weight : 0 ) * $quantity );
}
}
}
if ($total_weight < 3){
return 'billing code 1';
}else{
return 'billing code 2';
}
}
add_action('admin_init', 'iben_acs_custom_acccounts');
function iben_acs_custom_acccounts(){
// REQUIRE v1.6.0 and later
if ( ! class_exists( 'Iben_Woo_Acs_Admin_Woo' ) ) return;
if ( ! is_admin() ) return;
if ( !current_user_can( 'edit_shop_orders' ) ) return;
//display admin bar which account is assigned
add_filter( 'iben_acs_filter_display_multiaccount_message', '__return_true' );
//display in account column in vouchers list
add_filter( 'iben_acs_filter_vouchers_display_account_column', '__return_true' );
$current_id = get_current_user_id();
// ADMIN ID
if ($current_id == 1){
add_filter( 'iben_acs_main_company_id', function($default_value ) {
return 'xxxxx';
}, 10);
add_filter( 'iben_acs_main_company_password', function($default_value ) {
return 'xxxxxx';
}, 10);
add_filter( 'iben_acs_main_user_id', function($default_value ) {
return 'xxxxx';
}, 10
);
add_filter( 'iben_acs_main_user_password', function($default_value ) {
return '14411';
}, 10);
add_filter( 'iben_acs_main_apikey', function($default_value ) {
return 'e248xxxx3fca40af8ae8bb2cb6c4xxx';
}, 10);
add_filter( 'iben_acs_main_billing_code', function($default_value ) {
return 'xxxxxx';
}, 10);
// ADMIN ID
}elseif ($current_id == 2){
add_filter( 'iben_acs_main_company_id', function($default_value ) {
return 'demo';
}, 10);
add_filter( 'iben_acs_main_company_password', function($default_value ) {
return 'demo';
}, 10);
add_filter( 'iben_acs_main_user_id', function($default_value ) {
return 'demo';
}, 10
);
add_filter( 'iben_acs_main_user_password', function($default_value ) {
return 'demo';
}, 10);
add_filter( 'iben_acs_main_apikey', function($default_value ) {
return 'ff3981a2ac67410e877c1d73e7d83006';
}, 10);
add_filter( 'iben_acs_main_billing_code', function($default_value ) {
return '2ΑΘ999999';
}, 10);
}
}
// requires iBen ACS v2.5.1 and above
add_action('iben_acs_check_delivery_hook_after_delivered', 'iben_custom_trigger_function_delivered', 10, 2);
function iben_custom_trigger_function_delivered($order_id, $id_record){
if ( !function_exists( 'iben_acs_get_Vouchers_from_id' ) ) return;
$data = iben_acs_get_Vouchers_from_id($id_record);
if (empty($data) && !is_object($data) ) return;
$voucher = $data->acs_main_voucher;
$data = maybe_unserialize($data->acs_voucher_info);
//if COD
if (!isset($data['Cod_Ammount'])) return;
$cash = str_replace(",",".", $data['Cod_Ammount']);
$cash = floatval(preg_replace('/\.(?=.*\.)/', '', $cash));
if ($cash > 0){
// SEND EMAIL HERE
$headers = array('Content-Type: text/html; charset=UTF-8');
$subject = esc_html__( 'Just delivered a COD shipment', 'iben-woo-ups' );
$body = '<p> ACS voucher: '.$voucher.' ('.$cash.')</p>';
wp_mail( '[email protected]', $subject, $body, $headers );
}
}

add_filter( 'iben_acs_filter_listvouchers_displaycod_all', '__return_true' );
add_filter( 'iben_acs_filter_listvouchers_displaycod_delivered', '__return_true' );
add_filter( 'iben_acs_filter_listvouchers_displaycod_undelivered', '__return_true' );
Last modified 10mo ago