View_Product::add_tracking_attributes_to_button( array $options = array(), string $template = '' )
Summary
No summary available.Parameters
- $options
-
(array) (Optional)
Default value: array()
- $template
-
(string) (Optional)
Default value: ''
Return
(array)
Source
File: src/BigCommerce/Analytics/Events/View_Product.php
public function add_tracking_attributes_to_button( $options = [], $template = '' ) { if ( empty( $options[ View_Product_Button::PRODUCT ] ) ) { return $options; } /** @var Product $product */ $product = $options[ View_Product_Button::PRODUCT ]; if ( empty( $options[ View_Product_Button::ATTRIBUTES ] ) ) { $options[ View_Product_Button::ATTRIBUTES ] = []; } $options[ View_Product_Button::ATTRIBUTES ] = array_merge( $options[ View_Product_Button::ATTRIBUTES ], [ 'data-tracking-trigger' => 'click', 'data-tracking-event' => 'view_product', 'data-tracking-data' => wp_json_encode( [ 'post_id' => $product->post_id(), 'product_id' => $product->bc_id(), 'name' => get_the_title( $product->post_id() ), ] ), ] ); return $options; }