| @@ 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() ) { |
|
| @@ 146-161 (lines=16) @@ | ||
| 143 | * |
|
| 144 | * @return mixed. |
|
| 145 | */ |
|
| 146 | public function remove_from_cart_attributes( $url, $key ) { |
|
| 147 | if ( false !== strpos( $url, 'data-product_id' ) ) { |
|
| 148 | return $url; |
|
| 149 | } |
|
| 150 | ||
| 151 | $item = WC()->cart->get_cart_item( $key ); |
|
| 152 | $product = $item['data']; |
|
| 153 | ||
| 154 | $new_attributes = sprintf( |
|
| 155 | '" data-product_id="%s">', |
|
| 156 | esc_attr( $product->get_id() ) |
|
| 157 | ); |
|
| 158 | ||
| 159 | $url = str_replace( '">', $new_attributes, $url ); |
|
| 160 | return $url; |
|
| 161 | } |
|
| 162 | ||
| 163 | /** |
|
| 164 | * Gather relevant product information |
|