mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 09:08:09 +08:00
Prepare the SKU for sending to PayPal
This commit is contained in:
parent
53c2c96b8c
commit
dd6c76f328
3 changed files with 16 additions and 14 deletions
|
@ -66,7 +66,7 @@ class ItemFactory {
|
|||
$quantity,
|
||||
$this->prepare_description( $product->get_description() ),
|
||||
null,
|
||||
$product->get_sku(),
|
||||
$this->prepare_sku( $product->get_sku() ),
|
||||
( $product->is_virtual() ) ? Item::DIGITAL_GOODS : Item::PHYSICAL_GOODS,
|
||||
$product->get_permalink(),
|
||||
$image[0] ?? '',
|
||||
|
@ -143,7 +143,7 @@ class ItemFactory {
|
|||
$quantity,
|
||||
$product instanceof WC_Product ? $this->prepare_description( $product->get_description() ) : '',
|
||||
null,
|
||||
$product instanceof WC_Product ? $product->get_sku() : '',
|
||||
$product instanceof WC_Product ? $this->prepare_sku( $product->get_sku() ) : '',
|
||||
( $product instanceof WC_Product && $product->is_virtual() ) ? Item::DIGITAL_GOODS : Item::PHYSICAL_GOODS,
|
||||
$product instanceof WC_Product ? $product->get_permalink() : '',
|
||||
$image[0] ?? ''
|
||||
|
|
|
@ -21,4 +21,14 @@ trait ItemTrait {
|
|||
$description = strip_shortcodes( wp_strip_all_tags( $description ) );
|
||||
return substr( $description, 0, 127 ) ?: '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the sku for sending to PayPal.
|
||||
*
|
||||
* @param string $sku Item sku.
|
||||
* @return string
|
||||
*/
|
||||
protected function prepare_sku( string $sku ): string {
|
||||
return substr( wp_strip_all_tags( $sku ), 0, 127 ) ?: '';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue