Fixed add to cart link for simple products on feed

This commit is contained in:
Claudio Sanches 2019-08-30 14:22:28 -03:00
parent 1e0ff37d70
commit 282d6073ff
1 changed files with 9 additions and 2 deletions

View File

@ -39,8 +39,15 @@ class WC_Product_Simple extends WC_Product {
* @return string
*/
public function add_to_cart_url() {
$url = $this->is_purchasable() && $this->is_in_stock() ? remove_query_arg( 'added-to-cart', add_query_arg( 'add-to-cart', $this->id ) ) : get_permalink( $this->id );
$url = $this->is_purchasable() && $this->is_in_stock() ? remove_query_arg(
'added-to-cart',
add_query_arg(
array(
'add-to-cart' => $this->get_id(),
),
function_exists( 'is_feed' ) && is_feed() ? $this->get_permalink() : ''
)
) : $this->get_permalink();
return apply_filters( 'woocommerce_product_add_to_cart_url', $url, $this );
}