WooCommerce Website Integration
How to integrate WebSDK in WooCommerce Website?
Process of integrating WebSDK in WooCommerce Website is very simple.
<?php
add_action('wp_footer', function () {
global $current_user;
wp_get_current_user();
$islogged = is_user_logged_in();
$useremail = $current_user->user_email;
$userid = $current_user->id;
$username = $current_user->user_login;
$firstname = $current_user->user_firstname;
$lastname = $current_user->user_lastname;
?>
<script>
const nector = {
style: {
btn: {
desktop: {}, // support props: top, bottom, left, right
mobile: {} // support props: top, bottom, left, right
},
popup: {
desktop: {} // support props: top, bottom, left, right
}
}
};
nector.api_key = "your_api_key"; // paste your api key here
nector.identifier = "woocommerce";
nector.business_customer_id = '<?php echo $islogged == "1" ? $userid : "" ?>'
// nector.style.btn.desktop.bottom = "28px";
// nector.style.btn.desktop.left = "28px";
// nector.style.btn.mobile.bottom = "50px";
// nector.style.btn.mobile.left = "50px";
// nector.style.popup.desktop.bottom = "155px";
// nector.style.popup.desktop.left = "30px";
// nector.style.popup.desktop.left = "unset";
// renders the widgets
const randomString = "wSVNjD";
let elementId = `nector-rewards - widget - ${ randomString }`;
let rootElement = document.getElementById(elementId);
if (!rootElement) {
let newNectorElement = document.createElement("div");
newNectorElement.id = elementId;
document.body.appendChild(newNectorElement);
newNectorElement.style.zIndex = 100;
} else {
rootElement.style.zIndex = 100;
}
</script>
<script src="https://cdn.nector.io/nector-websdk-widget/main.min.js"></script>
<?php });
Upon successful integration a widget will be rendered at the bottom-left of the screen. Widget popup is your user's rewarding view.
Last modified 1yr ago