Lỗi này xuất hiện khá lâu từ tháng 6.2023 trên một số tài khoản thường, tới thời điểm tháng 10.2023 thì hầu hết các tài khoản Zalo mới lập đều gặp lỗi, bao gồm cả các tài khoản đã nâng Business và xác minh tài khoản (cmt + khuôn mặt + giọng nói) đầy đủ.
Lỗi trên diễn ra khá lâu nhưng hiện tại phía Zalo không có bản cập nhật cũng như thông báo rõ ràng về việc tiến hành điều chỉnh, nâng cấp hỗ trợ người dùng.
Trên mạng có một số bài viết hướng Liên hệ với đội ngũ Zalo để yêu cầu tư vấn, nâng cấp hoặc hỗ trợ thêm => Phương án mình đã thử thực hiện nhưng không có kết quả nên lúc đầu đã phải chuyển phương án sang dùng chat fb thay cho zalo
Để dễ hình dung về vấn đề thì có thể hiểu như sau: Khi vận hành website, quản trị viên sẽ setup 1 số Zalo nhân sự kinh doanh trên website để hỗ trợ khách hàng, trên các nút đó có link zalo.me/+SĐT để khách bấm vào để xem thông tin và chat với tư vấn viên qua Zalo nhưng lại bị lỗi như hình bên dưới:

Dưới đây là cách để mình tìm cách để giải quyết vấn đề này, cơ chế là lấy QR zalo để lấy thông tin chính xác ID tài khoản phục vụ dựng lại tính năng.
1. Không cần code – Cách này dành cho những website chỉ cẩn hiển thị button chat trên điện thoại
Đầu tiên các bạn vào tài khoản zalo, bấm vào biểu tượng QR Code góc trên cùng bên phải.

Sau đó bấm vào Mã QR của tôi:

Chọn Lưu về máy để sử dụng:

Các bạn sử dụng công cụ quét mã QR Code có sẵn trên điện thoại (không dùng của zalo), với máy mình nó là app Máy quét để quét mã QR Code vừa lưu bên trên.

Kết quả quét sẽ cho ra một đường link mới, các bạn lấy link này thay thế cho link cũ zalo.me/+SĐT là sẽ sử dụng được nút chat zalo bình thường.

Note: Lưu lại chuỗi ký tự 1b4mxwhqoaeag ở link bên trên, nó chính là mã qr code để bạn sử dụng trong phương pháp thứ 2.
2. Sử dụng code – Hỗ trợ iOs, android, PC và trình duyệt nếu PC chưa cài phần mềm zalo
Ưu điểm của code này:
- Tương thích với mọi button, không cần sửa lại link zale.me/{sđt} trên website đang có
- 1 hay nhiều sđt zalo trên website đều được
- Hỗ trợ iOs, android, PC và trình duyệt nếu PC chưa cài phần mềm zalo
Code sửa lỗi link zalo.me/{sđt}
Code này cần thay lại sđt và mã qr code cho đúng. Có thể thêm 01 hoặc nhiều số zalo tuỳ vào web của bạn nha.
2.1 Code chèn vào functions.php của web WordPress
Các bạn có thể dùng code sau để chèn vào functions.php của theme đang kích hoạt nhé. Nhớ đổi thông tin cho đúng
/*
* Code sửa lỗi link zalo.me/{sđt}
*/
add_action('wp_footer', 'devvn_fix_zalome', 999999);
function devvn_fix_zalome(){
?>
<script>
var zalo_acc = {
"sdtzalo1" : "mã qr code 1",
//"sdtzalo2" : "mã qr code 2",
};
function devvnCheckLinkAvailability(link, successCallback, errorCallback) {
var hiddenIframe = document.querySelector("#hiddenIframe");
if (!hiddenIframe) {
hiddenIframe = document.createElement("iframe");
hiddenIframe.id = "hiddenIframe";
hiddenIframe.style.display = "none";
document.body.appendChild(hiddenIframe);
}
var timeout = setTimeout(function () {
errorCallback("Link is not supported.");
window.removeEventListener("blur", handleBlur);
}, 2500);
var result = {};
function handleMouseMove(event) {
if (!result.x) {
result = {
x: event.clientX,
y: event.clientY,
};
}
}
function handleBlur() {
clearTimeout(timeout);
window.addEventListener("mousemove", handleMouseMove);
}
window.addEventListener("blur", handleBlur);
window.addEventListener(
"focus",
function onFocus() {
setTimeout(function () {
if (document.hasFocus()) {
successCallback(function (pos) {
if (!pos.x) {
return true;
}
var screenWidth =
window.innerWidth ||
document.documentElement.clientWidth ||
document.body.clientWidth;
var alertWidth = 300;
var alertHeight = 100;
var isXInRange =
pos.x - 100 < 0.5 * (screenWidth + alertWidth) &&
pos.x + 100 > 0.5 * (screenWidth + alertWidth);
var isYInRange =
pos.y - 40 < alertHeight && pos.y + 40 > alertHeight;
return isXInRange && isYInRange
? "Link can be opened."
: "Link is not supported.";
}(result));
} else {
successCallback("Link can be opened.");
}
window.removeEventListener("focus", onFocus);
window.removeEventListener("blur", handleBlur);
window.removeEventListener("mousemove", handleMouseMove);
}, 500);
},
{ once: true }
);
hiddenIframe.contentWindow.location.href = link;
}
Object.keys(zalo_acc).map(function(sdt, index) {
let qrcode = zalo_acc[sdt];
const zaloLinks = document.querySelectorAll('a[href*="zalo.me/'+sdt+'"]');
zaloLinks.forEach((zalo) => {
zalo.addEventListener("click", (event) => {
event.preventDefault();
const userAgent = navigator.userAgent.toLowerCase();
const isIOS = /iphone|ipad|ipod/.test(userAgent);
const isAndroid = /android/.test(userAgent);
let redirectURL = null;
if (isIOS) {
redirectURL = 'zalo://qr/p/'+qrcode;
window.location.href = redirectURL;
} else if (isAndroid) {
redirectURL = 'zalo://zaloapp.com/qr/p/'+qrcode;
window.location.href = redirectURL;
} else {
redirectURL = 'zalo://conversation?phone='+sdt;
zalo.classList.add("zalo_loading");
devvnCheckLinkAvailability(
redirectURL,
function (result) {
zalo.classList.remove("zalo_loading");
},
function (error) {
zalo.classList.remove("zalo_loading");
redirectURL = 'https://chat.zalo.me/?phone='+sdt;
window.location.href = redirectURL;
}
);
}
});
});
});
//Thêm css vào site để lúc ấn trên pc trong lúc chờ check chuyển hướng sẽ không ấn vào thẻ a đó được nữa
var styleElement = document.createElement("style");
var cssCode = ".zalo_loading { pointer-events: none; }";
styleElement.innerHTML = cssCode;
document.head.appendChild(styleElement);
</script>
<?php
}
2.2 Code chèn vào flatsome theme
Vào menu Flatsome > Advanced > Global Settings > BODY SCRIPTS – BOTTOM sau đó gán code sau vào nhé. Nhớ đổi thông tin cho đúng.
<script>
var zalo_acc = {
//"sdtzalo" : "mã qr code"
'09824154xx': 'hj8as2ynszxx',
};
function devvnCheckLinkAvailability(link, successCallback, errorCallback) {
var hiddenIframe = document.querySelector("#hiddenIframe");
if (!hiddenIframe) {
hiddenIframe = document.createElement("iframe");
hiddenIframe.id = "hiddenIframe";
hiddenIframe.style.display = "none";
document.body.appendChild(hiddenIframe);
}
var timeout = setTimeout(function () {
errorCallback("Link is not supported.");
window.removeEventListener("blur", handleBlur);
}, 2500);
var result = {};
function handleMouseMove(event) {
if (!result.x) {
result = {
x: event.clientX,
y: event.clientY,
};
}
}
function handleBlur() {
clearTimeout(timeout);
window.addEventListener("mousemove", handleMouseMove);
}
window.addEventListener("blur", handleBlur);
window.addEventListener(
"focus",
function onFocus() {
setTimeout(function () {
if (document.hasFocus()) {
successCallback(function (pos) {
if (!pos.x) {
return true;
}
var screenWidth =
window.innerWidth ||
document.documentElement.clientWidth ||
document.body.clientWidth;
var alertWidth = 300;
var alertHeight = 100;
var isXInRange =
pos.x - 100 < 0.5 * (screenWidth + alertWidth) &&
pos.x + 100 > 0.5 * (screenWidth + alertWidth);
var isYInRange =
pos.y - 40 < alertHeight && pos.y + 40 > alertHeight;
return isXInRange && isYInRange
? "Link can be opened."
: "Link is not supported.";
}(result));
} else {
successCallback("Link can be opened.");
}
window.removeEventListener("focus", onFocus);
window.removeEventListener("blur", handleBlur);
window.removeEventListener("mousemove", handleMouseMove);
}, 500);
},
{ once: true }
);
hiddenIframe.contentWindow.location.href = link;
}
Object.keys(zalo_acc).map(function(sdt, index) {
let qrcode = zalo_acc[sdt];
const zaloLinks = document.querySelectorAll('a[href*="zalo.me/'+sdt+'"]');
zaloLinks.forEach((zalo) => {
zalo.addEventListener("click", (event) => {
event.preventDefault();
const userAgent = navigator.userAgent.toLowerCase();
const isIOS = /iphone|ipad|ipod/.test(userAgent);
const isAndroid = /android/.test(userAgent);
let redirectURL = null;
if (isIOS) {
redirectURL = 'zalo://qr/p/'+qrcode;
window.location.href = redirectURL;
} else if (isAndroid) {
redirectURL = 'zalo://zaloapp.com/qr/p/'+qrcode;
window.location.href = redirectURL;
} else {
redirectURL = 'zalo://conversation?phone='+sdt;
zalo.classList.add("zalo_loading");
devvnCheckLinkAvailability(
redirectURL,
function (result) {
zalo.classList.remove("zalo_loading");
},
function (error) {
zalo.classList.remove("zalo_loading");
redirectURL = 'https://chat.zalo.me/?phone='+sdt;
window.location.href = redirectURL;
}
);
}
});
});
});
//Thêm css vào site để lúc ấn trên pc trong lúc chờ check chuyển hướng sẽ không ấn vào thẻ a đó được nữa
var styleElement = document.createElement("style");
var cssCode = ".zalo_loading { pointer-events: none; }";
styleElement.innerHTML = cssCode;
document.head.appendChild(styleElement);
</script>
Trong đoạn code trên bạn cần chú ý tới đoạn sau:
var zalo_acc = {
"sdtzalo1" : "mã qr code 1",
"sdtzalo2" : "mã qr code 2",
};
Đoạn này chính là sđt zalo của bạn và mã qr code của sđt đó. Ví dụ số zalo lỗi là 0123456 và mã qr lấy được là abcxyz thì sẽ sửa thành:
var zalo_acc = {
"0123456" : "abcxyz"
};
Cuối cùng hãy xoá toàn bộ cache của website nếu bạn đang sử dụng plugin tạo cache.
Vậy là xong rồi đó. Hướng dẫn cách lấy mã qr code như ở cách thứ 1.
Hướng dẫn đã hết, nếu các bạn thấy hay và hữu ích thì bình luận động viên + chia sẻ, nếu thấy không hay thì vẫn cứ bình luận động viên nhưng đừng chia sẻ. Chúc mọi người cuối tuần vui vẻ!