| @@ 253-268 (lines=16) @@ | ||
| 250 | /** |
|
| 251 | * Adds the product ID and SKU to the remove product link (for use by remove_from_cart above) if not present |
|
| 252 | */ |
|
| 253 | public function remove_from_cart_attributes( $url, $key ) { |
|
| 254 | if ( false !== strpos( $url, 'data-product_id' ) ) { |
|
| 255 | return $url; |
|
| 256 | } |
|
| 257 | ||
| 258 | $item = WC()->cart->get_cart_item( $key ); |
|
| 259 | $product = $item[ 'data' ]; |
|
| 260 | ||
| 261 | $new_attributes = sprintf( 'href="%s" data-product_id="%s" data-product_sku="%s"', |
|
| 262 | esc_attr( $url ), |
|
| 263 | esc_attr( $product->get_id() ), |
|
| 264 | esc_attr( $product->get_sku() ) |
|
| 265 | ); |
|
| 266 | $url = str_replace( 'href=', $new_attributes, $url ); |
|
| 267 | return $url; |
|
| 268 | } |
|
| 269 | ||
| 270 | public function listing_impression() { |
|
| 271 | if ( ! Jetpack_Google_Analytics_Options::enhanced_ecommerce_tracking_is_enabled() ) { |
|
| @@ 143-159 (lines=17) @@ | ||
| 140 | * @param string $key key. |
|
| 141 | * @return mixed. |
|
| 142 | */ |
|
| 143 | public function remove_from_cart_attributes( $url, $key ) { |
|
| 144 | if ( false !== strpos( $url, 'data-product_id' ) ) { |
|
| 145 | return $url; |
|
| 146 | } |
|
| 147 | ||
| 148 | $item = WC()->cart->get_cart_item( $key ); |
|
| 149 | $product = $item['data']; |
|
| 150 | ||
| 151 | $new_attributes = sprintf( |
|
| 152 | 'href="%s" data-product_id="%s" data-product_sku="%s"', |
|
| 153 | esc_attr( $url ), |
|
| 154 | esc_attr( $product->get_id() ), |
|
| 155 | esc_attr( $product->get_sku() ) |
|
| 156 | ); |
|
| 157 | $url = str_replace( 'href=', $new_attributes, $url ); |
|
| 158 | return $url; |
|
| 159 | } |
|
| 160 | ||
| 161 | /** |
|
| 162 | * Gather relevant product information |
|