woocommerce / woocommerce-gateway-paypal-express-checkout

59 stars 64 forks source link

Add filters #781

Closed ahegyes closed 3 years ago

ahegyes commented 4 years ago

Description

Added filters for retrieving the line items from cart and from orders.

We stumbled upon a situation where we needed to alter the name of the line items sent to PayPal to take into account custom product fields added with another plugin. Just using the filter inside of "product->get_name()" is not enough since we needed to include the information stored in the custom product fields inside the actual line items.

This was possible using WC's built-in PayPal integration (see filters "woocommerce_paypal_get_order_item_name" and "woocommerce_paypal_line_item" inside WooCommerce). This PR ensures parity in this regard with the built-in PayPal gateway.

Steps to test:

This doesn't make any changes to the way the plugin works. It just enables users to filter the line items sent to PayPal to include their own custom logic for generating them.

Documentation

Customers won't notice any changes.

ahegyes commented 3 years ago

Hello! Sorry to intervene, but I was wondering if there are any plans to merge this request or if this might've been rejected? Thank you!

jorgeatorres commented 3 years ago

Hi @ahegyes,

Thanks for taking the time to contribute! We apologize for the delay in responding. The filters look like a nice addition. My only concern was that they make the whole line item susceptible of being altered. Based on your PR and with the goal of limiting modifications to line item name/description, I've submitted PR #869. Hopefully these new filters will also work for your use case 😊.