Hello i did some changes in a Plugin but after Update i have to change every time the code. Now how to build an Filter for functions.php. Here are the changes i did.
they are just some variable changes. and i need these to sync it correctly.
i hope someone can help me build this:)
Here the Code of the ori Plugin
Ori:
protected function get_order_items($order) {
$order_items = array();
$incl_tax = get_option('woocommerce_tax_display_cart') == 'incl';
foreach ($order->get_items() as $item) {
if ($incl_tax) {
$price = ($item['line_subtotal'] + $item['line_subtotal_tax']) / $item['qty'];
} else {
$price = $item['line_subtotal'] / $item['qty']; // WC3+ ($item->get_subtotal()/$item->get_quantity()),
}
$product = $this->get_product_from_item($item);
$data = array(
'sku' => $product ? $product->get_sku() : '',
'name' => $item['name'], // WC3+ $item->get_name(),
'quantity' => $item['qty'], // WC3+ $item->get_quantity(),
'price' => $this->round_price($price),
'tax_id' => Options::get('bf_tax_' . ($item['tax_class'] ?: 'standard')), // WC3+ $item->get_tax_class();
'account_id' => Options::get('bf_account_products'),
);
$data = apply_filters('bf_wc_lq_connector_order_item_data', $data, $item, $product);
if (isset($item['variation_id'])) {
$data['text'] = $this->get_item_attribute_meta($item);
}
if (Options::get('bf_display_product_excerpt')) {
$excerpt = get_the_excerpt($item['product_id']);
if ($excerpt) {
$data['text'] = isset($data['text']) ? $data['text'] . $excerpt : $excerpt;
}
}
array_push($order_items, $data);
}
return $order_items;
}
Here are the changes of the variable.
Mod:
protected function get_order_items($order) {
$order_items = array();
$incl_tax = get_option('woocommerce_tax_display_cart') == 'incl';
foreach ($order->get_items() as $item) {
if ($incl_tax) {
$price = ($item['line_subtotal'] + $item['line_subtotal_tax']) / $item['qty'];
} else {
$price = $item['line_subtotal'] / $item['qty']; // WC3+ ($item->get_subtotal()/$item->get_quantity()),
}
$product = $this->get_product_from_item($item);
$posname = $item->get_meta("posname");
$pa_groesse = strtoupper($item->get_meta("pa_groesse"));
$pa_farbe = ucfirst($item->get_meta("pa_farbe"));
$nameneu = $posname . ' - ' . $pa_farbe .', ' . $pa_groesse;
$oriname = $item['name'];
if ( empty($posname) ) $nameneu = $oriname;
$artnr = strtoupper($item->get_meta("artnr"));
if ( empty($artnr) ) $artnr = $product ? $product->get_sku() : '';
$data = array(
'sku' => $artnr,
'name' => $nameneu, // WC3+ $item->get_name(),
'quantity' => $item['qty'], // WC3+ $item->get_quantity(),
'price' => $this->round_price($price),
'tax_id' => Options::get('bf_tax_' . ($item['tax_class'] ?: 'standard')), // WC3+ $item->get_tax_class();
'account_id' => Options::get('bf_account_products'),
);
$data = apply_filters('bf_wc_lq_connector_order_item_data', $data, $item, $product);
if (array_key_exists('variation_id', $item)) {
$data['text'] = $this->get_item_attribute_meta($item);
}
if (Options::get('bf_display_product_excerpt')) {
$excerpt = get_the_excerpt($item['product_id']);
if ($excerpt) {
$data['text'] = isset($data['text']) ? $data['text'] . $excerpt : $excerpt;
}
}
array_push($order_items, $data);
}
return $order_items;
}
2
Answers
Now with help of passerby i did the first step.
the other step is
i have in same file this code
ori is this code:
Maybe you can update the &data parameter as per the code below: