--- a/woocommerce-pdf-invoices-packing-slips/edi/Abstracts/AbstractHandler.php
+++ b/woocommerce-pdf-invoices-packing-slips/edi/Abstracts/AbstractHandler.php
@@ -107,6 +107,7 @@
$mapping = apply_filters( 'wpo_ips_edi_payment_means_code_mapping', array(
+ 'cheque' => '20', // Cheque
'bacs' => '58', // SEPA Credit Transfer
'paypal' => '68', // Online payment
'stripe' => '54', // Credit card
@@ -141,9 +142,10 @@
case 'stripe':
$data['transaction_id'] = $order->get_meta( '_stripe_source_id', true );
break;
+
}
- return $data;
+ return apply_filters( 'wpo_ips_edi_payment_means_data', $data, $method_id, $order, $this );
}
/**
--- a/woocommerce-pdf-invoices-packing-slips/edi/Syntaxes/Cii/Handlers/SupplyChainTradeTransaction/IncludedSupplyChainTradeLineItemHandler.php
+++ b/woocommerce-pdf-invoices-packing-slips/edi/Syntaxes/Cii/Handlers/SupplyChainTradeTransaction/IncludedSupplyChainTradeLineItemHandler.php
@@ -138,8 +138,8 @@
$quantity_value = $parts['qty'];
- // Use Woo’s net_total for the line total amount.
- $net_line_total_f = (float) $this->format_decimal( $parts['net_total'], 2 );
+ // Compute line net amount from the same unit price we emit in ChargeAmount
+ $net_line_total_f = (float) $this->format_decimal( $net_unit_f * $quantity_value, 2 );
$net_line_total = $this->format_decimal( $net_line_total_f, 2 );
$line_item = array(
--- a/woocommerce-pdf-invoices-packing-slips/edi/Syntaxes/Ubl/Handlers/LineHandler.php
+++ b/woocommerce-pdf-invoices-packing-slips/edi/Syntaxes/Ubl/Handlers/LineHandler.php
@@ -185,8 +185,8 @@
$quantity_value = -abs( $quantity_value );
}
- // Use Woo’s net_total for the line extension amount.
- $net_line_total = $this->format_decimal( $parts['net_total'], 2 );
+ // Compute line net amount from the same unit price we emit in PriceAmount
+ $net_line_total = $this->format_decimal( $net_unit_f * $quantity_value, 2 );
$line = array(
'name' => "cac:{$root_element}Line",
--- a/woocommerce-pdf-invoices-packing-slips/includes/Admin.php
+++ b/woocommerce-pdf-invoices-packing-slips/includes/Admin.php
@@ -894,41 +894,69 @@
* @return void
*/
public function ajax_edi_save_order_customer_peppol_identifiers(): void {
+ // Nonce check.
if ( ! check_ajax_referer( 'generate_wpo_wcpdf', 'security', false ) ) {
- wp_send_json_error( array(
- 'message' => __( 'Invalid security token.', 'woocommerce-pdf-invoices-packing-slips' )
- ) );
+ wp_send_json_error(
+ array(
+ 'message' => __( 'Invalid security token.', 'woocommerce-pdf-invoices-packing-slips' ),
+ )
+ );
+ }
+
+ // Authorization.
+ if ( ! current_user_can( 'edit_shop_orders' ) ) {
+ wp_send_json_error(
+ array(
+ 'message' => __( 'You do not have permission to perform this action.', 'woocommerce-pdf-invoices-packing-slips' ),
+ ),
+ 403
+ );
}
$request = stripslashes_deep( $_POST );
$order_id = isset( $request['order_id'] ) ? absint( $request['order_id'] ) : 0;
- $values = isset( $request['values'] ) ? $request['values'] : array();
+ $values = isset( $request['values'] ) && is_array( $request['values'] ) ? $request['values'] : array();
- if ( empty( $order_id ) || empty( $values ) ) {
- wp_send_json_error( array(
- 'message' => __( 'Invalid order ID or values.', 'woocommerce-pdf-invoices-packing-slips' )
- ) );
+ if ( ! $order_id || empty( $values ) ) {
+ wp_send_json_error(
+ array(
+ 'message' => __( 'Invalid order ID or values.', 'woocommerce-pdf-invoices-packing-slips' ),
+ ),
+ 400
+ );
}
$order = wc_get_order( $order_id );
if ( ! $order ) {
- wp_send_json_error( array(
- 'message' => __( 'Order not found.', 'woocommerce-pdf-invoices-packing-slips' )
- ) );
+ wp_send_json_error(
+ array(
+ 'message' => __( 'Order not found.', 'woocommerce-pdf-invoices-packing-slips' ),
+ ),
+ 404
+ );
}
- $customer_id = is_callable( array( $order, 'get_customer_id' ) )
- ? $order->get_customer_id()
- : 0;
+ // Ensure the current user can edit this order in admin.
+ if ( ! current_user_can( 'edit_post', $order->get_id() ) ) {
+ wp_send_json_error(
+ array(
+ 'message' => __( 'You do not have permission to edit this order.', 'woocommerce-pdf-invoices-packing-slips' ),
+ ),
+ 403
+ );
+ }
- wpo_ips_edi_peppol_save_customer_identifiers( $customer_id, $values );
+ $customer_id = is_callable( array( $order, 'get_customer_id' ) ) ? (int) $order->get_customer_id() : 0;
+ wpo_ips_edi_peppol_save_customer_identifiers( $customer_id, $values );
wpo_ips_edi_maybe_save_order_peppol_data( $order, $values );
- wp_send_json_success( array(
- 'message' => __( 'Peppol identifiers saved successfully.', 'woocommerce-pdf-invoices-packing-slips' ),
- ) );
+ wp_send_json_success(
+ array(
+ 'message' => __( 'Peppol identifiers saved successfully.', 'woocommerce-pdf-invoices-packing-slips' ),
+ )
+ );
}
public function data_input_box_content( $post_or_order_object ) {
--- a/woocommerce-pdf-invoices-packing-slips/woocommerce-pdf-invoices-packingslips.php
+++ b/woocommerce-pdf-invoices-packing-slips/woocommerce-pdf-invoices-packingslips.php
@@ -4,14 +4,14 @@
* Requires Plugins: woocommerce
* Plugin URI: https://wpovernight.com/downloads/woocommerce-pdf-invoices-packing-slips-bundle/
* Description: Create, print & email PDF or Electronic Invoices & PDF Packing Slips for WooCommerce orders.
- * Version: 5.6.0
+ * Version: 5.7.0
* Author: WP Overnight
* Author URI: https://www.wpovernight.com
* License: GPLv2 or later
* License URI: https://opensource.org/licenses/gpl-license.php
* Text Domain: woocommerce-pdf-invoices-packing-slips
* WC requires at least: 3.3
- * WC tested up to: 10.4
+ * WC tested up to: 10.5
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -22,7 +22,7 @@
class WPO_WCPDF {
- public $version = '5.6.0';
+ public $version = '5.7.0';
public $version_php = '7.4';
public $version_woo = '3.3';
public $version_wp = '4.4';
--- a/woocommerce-pdf-invoices-packing-slips/wpo-ips-functions-edi.php
+++ b/woocommerce-pdf-invoices-packing-slips/wpo-ips-functions-edi.php
@@ -126,7 +126,7 @@
if ( ! wpo_ips_edi_peppol_is_available() ) {
return; // only save for Peppol formats
}
-
+
$identifier = '';
$scheme = '';
$save_meta_data = false;
@@ -148,12 +148,12 @@
$identifier = $raw;
}
}
-
+
if ( empty( $identifier ) || empty( $scheme ) ) {
$customer_id = is_callable( array( $order, 'get_customer_id' ) )
? $order->get_customer_id()
: 0;
-
+
if ( $customer_id <= 0 ) {
return;
}
@@ -175,7 +175,7 @@
if ( ! $save_meta_data ) {
return;
}
-
+
$order->save_meta_data();
}
@@ -780,7 +780,7 @@
if ( $user_id <= 0 ) {
return;
}
-
+
$mode = wpo_ips_edi_peppol_identifier_input_mode();
// [ text‑field , scheme‑field ]
@@ -877,13 +877,23 @@
return '';
}
+ $atts = apply_filters(
+ 'wpo_ips_edi_generate_action_button_html_atts',
+ array(
+ 'url' => $url,
+ 'class' => $class,
+ 'label' => $label,
+ 'icon' => $icon,
+ )
+ );
+
return sprintf(
'<a href="%1$s" class="%2$s" alt="%3$s" title="%3$s">
<span class="dashicons %4$s"></span>
</a>',
- esc_url( $url ),
- esc_attr( $class ),
- esc_attr( $label ),
- esc_attr( $icon )
+ esc_url( $atts['url'] ),
+ esc_attr( $atts['class'] ),
+ esc_attr( $atts['label'] ),
+ esc_attr( $atts['icon'] )
);
}