Add woocommerce_cart_item_permalink filter to cart endpoint (https://github.com/woocommerce/woocommerce-blocks/pull/8726)
This commit is contained in:
parent
a85b80e6ac
commit
ef97fad080
|
@ -335,6 +335,20 @@ class CartItemSchema extends ProductSchema {
|
|||
public function get_item_response( $cart_item ) {
|
||||
$product = $cart_item['data'];
|
||||
|
||||
/**
|
||||
* Filter the product permalink.
|
||||
*
|
||||
* This is a hook taken from the legacy cart/mini-cart templates that allows the permalink to be changed for a
|
||||
* product. This is specific to the cart endpoint.
|
||||
*
|
||||
* @since 9.9.0
|
||||
*
|
||||
* @param string $product_permalink Product permalink.
|
||||
* @param array $cart_item Cart item array.
|
||||
* @param string $cart_item_key Cart item key.
|
||||
*/
|
||||
$product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $product->get_permalink(), $cart_item, $cart_item['key'] );
|
||||
|
||||
return [
|
||||
'key' => $cart_item['key'],
|
||||
'id' => $product->get_id(),
|
||||
|
@ -348,7 +362,7 @@ class CartItemSchema extends ProductSchema {
|
|||
'backorders_allowed' => (bool) $product->backorders_allowed(),
|
||||
'show_backorder_badge' => (bool) $product->backorders_require_notification() && $product->is_on_backorder( $cart_item['quantity'] ),
|
||||
'sold_individually' => $product->is_sold_individually(),
|
||||
'permalink' => $product->get_permalink(),
|
||||
'permalink' => $product_permalink,
|
||||
'images' => $this->get_images( $product ),
|
||||
'variation' => $this->format_variation_data( $cart_item['variation'], $product ),
|
||||
'item_data' => $this->get_item_data( $cart_item ),
|
||||
|
|
Loading…
Reference in New Issue