term_id; $productCategoryName = $productTerm->name; if (!array_key_exists($productCategoryId, $categories)) { $categories[$productCategoryId] = array( 'name' => $productCategoryName, 'counter' => 1 ); } else { $categories[$productCategoryId]['counter']++; } } } } $categoryCounter = 0; $categoryId = 0; $categoryName = ''; foreach($categories as $id => $category) { if($category['counter'] > $categoryCounter) { $categoryId = $id; $categoryName = rawurlencode($category['name']); $categoryCounter = $category['counter']; } } $productIdString = implode(';', $productIds); if(is_search()) { $roleWcAdcellTrackingScriptRetargeting = 'https://t.adcell.com/js/inlineretarget.js?s=wordpress&sv='. $wp_version . '&v=' . ROLE_WC_ADCELL_VERSION . '&cv=' . ROLE_WC_ADCELL_CV . '&method=search&pid='.esc_attr(get_option('roleWcAdcellProgramId')).'&search='. rawurlencode(get_search_query(false)) .'&productIds='. $productIdString .'&productSeparator=;'.'&faktor=2'; } else { $roleWcAdcellTrackingScriptRetargeting = 'https://t.adcell.com/js/inlineretarget.js?s=wordpress&sv='. $wp_version . '&v=' . ROLE_WC_ADCELL_VERSION . '&cv=' . ROLE_WC_ADCELL_CV . '&method=category&pid='.esc_attr(get_option('roleWcAdcellProgramId')).'&categoryName='.$categoryName.'&categoryId='. $categoryId .'&productIds='. $productIdString . '&productSeparator=;'.'&faktor=2'; } RoleWcAdcell::footer_script($roleWcAdcellTrackingScriptRetargeting); } function roleWcAdcellTrackingProductRetargeting() { global $product; global $wp_version; $relatedProducts = wc_get_related_products($product->get_id()); $relatedProductsString = implode(';', $relatedProducts); $categoryIds = $product->get_category_ids(); $categoryId = ! empty( $categoryIds ) ? $categoryIds[0] : 0; RoleWcAdcell::footer_script('https://t.adcell.com/js/inlineretarget.js?s=wordpress&sv='. $wp_version . '&v=' . ROLE_WC_ADCELL_VERSION . '&cv=' . ROLE_WC_ADCELL_CV . '&method=product&pid='.esc_attr(get_option('roleWcAdcellProgramId')).'&productId='. $product->get_id() .'&productName='. rawurlencode($product->get_name()) .'&categoryId='. $categoryId .'&productIds='. $relatedProductsString .'&productSeparator=;'.'&faktor=2'); } function roleWcAdcellTrackingCartRetargeting() { global $woocommerce; global $wp_version; $items = $woocommerce->cart->get_cart(); $cartProducts = array(); $cartQuantities = array(); $cartCount = 0; $cartAmount = 0.0; foreach($items as $item => $values) { $cartProducts[] = $values['data']->get_id(); $cartQuantities[] = $values['quantity']; $cartCount += $values['quantity']; $cartAmount += $values['line_total']; } $cartProductsString = implode(';', $cartProducts); $cartQuantitiesString = implode(';', $cartQuantities); RoleWcAdcell::footer_script('https://t.adcell.com/js/inlineretarget.js?s=wordpress&sv='. $wp_version . '&v=' . ROLE_WC_ADCELL_VERSION . '&cv=' . ROLE_WC_ADCELL_CV . '&method=basket&pid='.esc_attr(get_option('roleWcAdcellProgramId')).'&productIds='. $cartProductsString .'&productSeparator=;&quantities='. $cartQuantitiesString .'&basketProductCount='. $cartCount .'&basketTotal='. $cartAmount.'&faktor=2'); } function roleWcAdcellTrackingOrderRetargeting($wcOrder) { global $wp_version; $total = round(RoleWcAdcellOrderAmounts::goods_total($wcOrder), 2); $items = $wcOrder->get_items(); $orderProducts = array(); $orderQuantities = array(); $orderCount = 0; foreach($items as $item => $values) { $orderProducts[] = $values['product_id']; $orderQuantities[] = $values['quantity']; $orderCount += $values['quantity']; } $orderProductsString = implode(';', $orderProducts); $orderQuantitiesString = implode(';', $orderQuantities); RoleWcAdcell::footer_script('https://t.adcell.com/js/inlineretarget.js?s=wordpress&sv='. $wp_version . '&v=' . ROLE_WC_ADCELL_VERSION . '&cv=' . ROLE_WC_ADCELL_CV . '&method=checkout&pid='. esc_attr(get_option('roleWcAdcellProgramId')) . '&basketId='. $wcOrder->get_order_number() .'&basketTotal='. $total .'&basketProductCount='. $orderCount .'&productIds='. $orderProductsString .'&productSeparator=;&quantities='. $orderQuantitiesString.'&faktor=2'); }