Skip to content

Instantly share code, notes, and snippets.

Created June 16, 2017 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4f81e98e1c4595e33bed49dca22bd061 to your computer and use it in GitHub Desktop.
Save anonymous/4f81e98e1c4595e33bed49dca22bd061 to your computer and use it in GitHub Desktop.
<?php
add_action( 'woocommerce_thankyou', 'ebit_banner' );
function ebit_banner( $order_id ) {
$store_id = ''; // o ID da sua loja
$buscape_id = ''; // o ID único do Buscapé
$order = wc_get_order( $order_id );
$order_items = $order->get_items();
foreach ( $order_items as $item ) {
$product = wc_get_product( $item['product_id'] );
$product_name[] = $product->get_title();
$sku[] = $product->get_sku();
$qty[] = $item['qty'];
$total[] = $item['line_total'];
}
$email = $order->billing_email;
$totalSpent = $order->get_total();
$deliveryTax = $order->get_shipping_tax();
$value = implode( '|', $total );
$quantity = implode( '|', $qty );
$productName = implode( '|', $product_name );
$sku = implode("|", $sku);
echo '<param id="ebitParam" value="email='. $email .
'&deliveryTax='. $deliveryTax .
'&totalSpent='. $totalSpent .
'&value='. $value .
'&quantity='. $quantity .
'&productName='. $productName .
'&transactionId='. $order_id .
'&sku='. $sku .
'&buscapeId=' . $buscape_id . '&storeId=' . $store_id . '&plataform=0"/>';
echo '<a id="bannerEbit"></a>';
echo '<script type="text/javascript" id="getSelo" src="https://imgs.ebit.com.br/ebitBR/selo-ebit/js/getSelo.js?' . $store_id . '&lightbox=true"></script>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment