| @@ 250-266 (lines=17) @@ | ||
| 247 | * @param string $url Full HTML a tag of the link to remove an item from the cart. |
|
| 248 | * @param string $key Unique Key ID for a cart item. |
|
| 249 | */ |
|
| 250 | public function remove_from_cart_attributes( $url, $key ) { |
|
| 251 | if ( false !== strpos( $url, 'data-product_id' ) ) { |
|
| 252 | return $url; |
|
| 253 | } |
|
| 254 | ||
| 255 | $item = WC()->cart->get_cart_item( $key ); |
|
| 256 | $product = $item['data']; |
|
| 257 | ||
| 258 | $new_attributes = sprintf( |
|
| 259 | '" data-product_id="%1$s" data-product_sku="%2$s">', |
|
| 260 | esc_attr( $product->get_id() ), |
|
| 261 | esc_attr( $product->get_sku() ) |
|
| 262 | ); |
|
| 263 | ||
| 264 | $url = str_replace( '">', $new_attributes, $url ); |
|
| 265 | return $url; |
|
| 266 | } |
|
| 267 | ||
| 268 | public function listing_impression() { |
|
| 269 | if ( ! Jetpack_Google_Analytics_Options::enhanced_ecommerce_tracking_is_enabled() ) { |
|
| @@ 201-216 (lines=16) @@ | ||
| 198 | * |
|
| 199 | * @return mixed. |
|
| 200 | */ |
|
| 201 | public function remove_from_cart_attributes( $url, $key ) { |
|
| 202 | if ( false !== strpos( $url, 'data-product_id' ) ) { |
|
| 203 | return $url; |
|
| 204 | } |
|
| 205 | ||
| 206 | $item = WC()->cart->get_cart_item( $key ); |
|
| 207 | $product = $item['data']; |
|
| 208 | ||
| 209 | $new_attributes = sprintf( |
|
| 210 | '" data-product_id="%s">', |
|
| 211 | esc_attr( $product->get_id() ) |
|
| 212 | ); |
|
| 213 | ||
| 214 | $url = str_replace( '">', $new_attributes, $url ); |
|
| 215 | return $url; |
|
| 216 | } |
|
| 217 | ||
| 218 | /** |
|
| 219 | * Gather relevant product information |
|