mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 14:57:26 +08:00
Merge branch 'trunk' into PCP-2786-do-not-save-payment-token-for-guest-users
This commit is contained in:
commit
16a8c9a313
11 changed files with 71 additions and 35 deletions
|
@ -61,10 +61,10 @@ class ItemFactory {
|
|||
|
||||
$price = (float) $item['line_subtotal'] / (float) $item['quantity'];
|
||||
return new Item(
|
||||
mb_substr( $product->get_name(), 0, 127 ),
|
||||
$this->prepare_item_string( $product->get_name() ),
|
||||
new Money( $price, $this->currency ),
|
||||
$quantity,
|
||||
$this->prepare_description( $product->get_description() ),
|
||||
$this->prepare_item_string( $product->get_description() ),
|
||||
null,
|
||||
$this->prepare_sku( $product->get_sku() ),
|
||||
( $product->is_virtual() ) ? Item::DIGITAL_GOODS : Item::PHYSICAL_GOODS,
|
||||
|
@ -138,10 +138,10 @@ class ItemFactory {
|
|||
$image = $product instanceof WC_Product ? wp_get_attachment_image_src( (int) $product->get_image_id(), 'full' ) : '';
|
||||
|
||||
return new Item(
|
||||
mb_substr( $item->get_name(), 0, 127 ),
|
||||
$this->prepare_item_string( $item->get_name() ),
|
||||
new Money( $price_without_tax_rounded, $currency ),
|
||||
$quantity,
|
||||
$product instanceof WC_Product ? $this->prepare_description( $product->get_description() ) : '',
|
||||
$product instanceof WC_Product ? $this->prepare_item_string( $product->get_description() ) : '',
|
||||
null,
|
||||
$product instanceof WC_Product ? $this->prepare_sku( $product->get_sku() ) : '',
|
||||
( $product instanceof WC_Product && $product->is_virtual() ) ? Item::DIGITAL_GOODS : Item::PHYSICAL_GOODS,
|
||||
|
@ -160,7 +160,7 @@ class ItemFactory {
|
|||
*/
|
||||
private function from_wc_order_fee( \WC_Order_Item_Fee $item, \WC_Order $order ): Item {
|
||||
return new Item(
|
||||
$item->get_name(),
|
||||
$this->prepare_item_string( $item->get_name() ),
|
||||
new Money( (float) $item->get_amount(), $order->get_currency() ),
|
||||
$item->get_quantity(),
|
||||
'',
|
||||
|
|
|
@ -12,14 +12,14 @@ namespace WooCommerce\PayPalCommerce\ApiClient\Helper;
|
|||
trait ItemTrait {
|
||||
|
||||
/**
|
||||
* Cleanups the description and prepares it for sending to PayPal.
|
||||
* Cleans up item strings (title and description for example) and prepares them for sending to PayPal.
|
||||
*
|
||||
* @param string $description Item description.
|
||||
* @param string $string Item string.
|
||||
* @return string
|
||||
*/
|
||||
protected function prepare_description( string $description ): string {
|
||||
$description = strip_shortcodes( wp_strip_all_tags( $description ) );
|
||||
return substr( $description, 0, 127 ) ?: '';
|
||||
protected function prepare_item_string( string $string ): string {
|
||||
$string = strip_shortcodes( wp_strip_all_tags( $string ) );
|
||||
return substr( $string, 0, 127 ) ?: '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue