Skip to content

Commit

Permalink
Merge branch 'main' into revision
Browse files Browse the repository at this point in the history
  • Loading branch information
robbyald authored Nov 25, 2024
2 parents 4ee1207 + 1f70b8d commit 2dd6eeb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
36 changes: 30 additions & 6 deletions woo-doku-jokul/Module/JokulCheckoutModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function get_order_data($order)
'price' => wc_format_decimal($order->get_item_total($item, false, false), $dp),
'quantity' => wc_stock_amount($item['qty']),
'name' => preg_replace($pattern, "", $item['name']),
'sku' => !empty($product_sku) ? $product_sku : 'empty sku',
'sku' => !empty($product_sku) ? $product_sku : $product_id,
'type' => 'produk',
'category' => 'marketplace',
'image_url' => !empty($image_url) ? $image_url : '',
Expand All @@ -125,25 +125,49 @@ public function get_order_data($order)
'id' => $product_id,
'name' => preg_replace($pattern, "", $shipping_item['name']),
'price' => wc_format_decimal($shipping_item['cost'], $dp),
'quantity' => '1',
'sku' => !empty($product_sku) ? $product_sku : 'empty sku',
'quantity' => 1,
'sku' => 'shipping',
'type' => 'produk',
'category' => 'marketplace',
'category' => 'fee',
'image_url' => !empty($image_url) ? $image_url : '',
'url' => $product_url
);
}
}
// Add taxes.
foreach ($order->get_tax_totals() as $tax_code => $tax) {
$product = $order->get_product_from_item($item);
if (is_object($product)) {
$product_id = isset($product->variation_id) ? $product->variation_id : $product->id;
}
if (wc_format_decimal($tax->amount, $dp) > 0) {
$order_data[] = array('name' => preg_replace($pattern, "", $tax->label), 'price' => wc_format_decimal($tax->amount, $dp), 'quantity' => '1', 'sku' => '0', 'category' => 'uncategorized', 'url' => 'https://www.doku.com/');
$order_data[] = array(
'id' => $product_id,
'name' => preg_replace($pattern, "", $tax->label),
'price' => wc_format_decimal($tax->amount, $dp),
'quantity' => 1,
'type' => 'produk',
'sku' => 'tax-' . $product_id . '-' . preg_replace($pattern, "", $tax->label),
'category' => 'fee',
);
}
}
// Add fees.
foreach ($order->get_fees() as $fee_item_id => $fee_item) {
$product = $order->get_product_from_item($item);
if (is_object($product)) {
$product_id = isset($product->variation_id) ? $product->variation_id : $product->id;
}
if (wc_format_decimal($order->get_line_total($fee_item), $dp) > 0) {
$order_data[] = array('name' => preg_replace($pattern, "", $fee_item['name']), 'price' => wc_format_decimal($order->get_line_total($fee_item), $dp), 'quantity' => '1', 'sku' => '0', 'category' => 'uncategorized', 'url' => 'https://www.doku.com/');
$order_data[] = array(
'id' => $product_id,
'name' => preg_replace($pattern, "", $fee_item['name']),
'price' => wc_format_decimal($order->get_line_total($fee_item), $dp),
'quantity' => 1,
'type' => 'produk',
'sku' => 'fee-' . $product_id . '-' . preg_replace($pattern, "", $tax->label),
'category' => 'fee',
);
}
}
$order_data = apply_filters('woocommerce_cli_order_data', $order_data);
Expand Down
4 changes: 4 additions & 0 deletions woo-doku-jokul/Service/JokulCheckoutService.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function generated($config, $params)
"line_items" => $params['itemQty'],
"amount" => $params['amount'],
"callback_url" => $params['callback_url'],
"callback_url_cancel" => "https://www.doku.com/en-US",
"currency" => "IDR",
"auto_redirect" => true,
"disable_retry_payment" => true
Expand All @@ -32,6 +33,7 @@ public function generated($config, $params)
"line_items" => $params['itemQty'],
"amount" => $params['amount'],
"callback_url" => $params['callback_url'],
"callback_url_cancel" => "https://www.doku.com/en-US",
"currency" => "IDR"
),
"payment" => array(
Expand Down Expand Up @@ -85,6 +87,7 @@ public function generated($config, $params)
"line_items" => $params['itemQty'],
"amount" => $params['amount'],
"callback_url" => $params['callback_url'],
"callback_url_cancel" => "https://www.doku.com/en-US",
"currency" => "IDR",
"auto_redirect" => true,
"disable_retry_payment" => true
Expand All @@ -93,6 +96,7 @@ public function generated($config, $params)
"line_items" => $params['itemQty'],
"amount" => $params['amount'],
"callback_url" => $params['callback_url'],
"callback_url_cancel" => "https://www.doku.com/en-US",
"currency" => "IDR"
),
"payment" => array(
Expand Down

0 comments on commit 2dd6eeb

Please sign in to comment.