# sync-basalam/1.10.21/assets/js/vendor-status.js

ووسلام – همگام سازی ووکامرس و باسلام, version 1.10.21. 63 lines.

- Page: https://pluginprobe.com/plugins/sync-basalam/1.10.21/code/assets/js/vendor-status.js
- Raw: https://pluginprobe.com/plugins/sync-basalam/1.10.21/raw/assets/js/vendor-status.js
- Modified: 2026-09-20T11:25:32+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/sync-basalam/1.10.21/code/assets/js/vendor-status.js#L10-L20`.

```javascript
document.addEventListener("DOMContentLoaded", function () {
  const button = document.getElementById(
    "sync_basalam_refresh_vendor_status_btn"
  );

  if (!button) return;

  const showToast = (type, message) => {
    if (window.BasalamToast && typeof window.BasalamToast[type] === "function") {
      window.BasalamToast[type](message);
      return;
    }

    window.alert(message);
  };

  button.addEventListener("click", function () {
    if (button.disabled) return;

    const originalText = button.textContent;
    const formData = new FormData();
    formData.append("action", "sync_basalam_refresh_vendor_status");
    formData.append("_wpnonce", button.dataset.nonce || "");

    button.disabled = true;
    button.textContent = "در حال بررسی...";

    fetch(window.ajaxurl, {
      method: "POST",
      credentials: "same-origin",
      body: formData,
    })
      .then((response) => response.json())
      .then((response) => {
        const data = response.data || {};

        if (!response.success) {
          throw new Error(data.message || "بررسی وضعیت غرفه ناموفق بود.");
        }

        const isActive = data.state && data.state.mode === "active";
        showToast(
          isActive ? "success" : "warning",
          data.message ||
            (isActive
              ? "غرفه فعال شد."
              : "غرفه هنوز در باسلام غیرفعال است.")
        );

        window.setTimeout(function () {
          window.location.reload();
        }, 600);
      })
      .catch((error) => {
        showToast("error", error.message || "خطا در ارتباط با سرور.");
      })
      .finally(() => {
        button.disabled = false;
        button.textContent = originalText;
      });
  });
});

```
