تخطي للذهاب إلى المحتوى
أودو القائمة
  • تسجيل الدخول
  • جرب مجاناً
  • التطبيقات
    المالية
    • المحاسبة
    • فوترة
    • النفقات
    • جدول البيانات (BI)
    • المستندات
    • توقيع إلكتروني
    المبيعات
    • إدارة علاقات العملاء
    • المبيعات
    • نقطة البيع للمتاجر
    • نقطة البيع للمطاعم
    • الاشتراكات
    • تأجير
    المواقع الإلكترونية
    • أداة بناء المواقع الإلكترونية
    • متاجر إلكترونية
    • مدونة
    • المنتدى
    • دردشة مباشرة
    • التعليم الإلكتروني
    سلسلة التوريد
    • المستودعات
    • التصنيع
    • إدارة دورة حياة المنتج
    • المشتريات
    • الصيانة
    • الجودة
    الموارد البشرية
    • موظفون
    • التوظيف
    • إجازة عمل
    • التقييمات
    • الإحالات
    • تطبيق الأسطول
    التسويق
    • التسويق الإجتماعي
    • التسويق عبر البريد الإلكتروني
    • التسويق عبر الرسائل النصية
    • فعاليات
    • أتمتة التسويق
    • الاستطلاعات
    الخدمات
    • المشاريع
    • الجداول الزمنية
    • الخدمة الميدانية
    • مكتب المساعدة
    • التخطيط
    • مواعيد
    اﻹنتاجية
    • مناقشة
    • الموافقات
    • إنترنت الأشياء "IoT"
    • بروتوكول ربط المحادثات الصوتية عبر الإنترنت
    • المعرفة
    • WhatsApp
    التطبيقات الخارجية ستوديو أودو منصة أودو السحابية
  • قطاعات الأعمال
    البيع بالتجزئة
    • متجر كتب
    • متجر ملابس
    • متجر أثاث
    • متجر بقالة
    • متجر معدات
    • متجر ألعاب
    الطعام والضيافة
    • بار وحانة
    • المطعم
    • مطعم للوجبات السريعة
    • نزل للضيوف
    • موزّع مشروبات
    • فندق
    العقارات
    • وكالة عقارات
    • شركة هندسة معمارية
    • البناء
    • إدارة العقارات
    • العناية بالحدائق
    • اتحاد مُلاّك العقارات
    استشارة
    • مؤسسة محاسبية
    • شريك أودو
    • وكالة تسويقية
    • منشأة قانونية
    • استقطاب المواهب
    • التدقيق والتوثيق
    التصنيع
    • الأقمشة
    • معدني
    • الأثاث
    • الطعام
    • مصنع خمور
    • هدايا الشركات
    الصحة واللياقة البدنية
    • نادي رياضي
    • متجر نظارات
    • مركز لياقة بدنية
    • الممارسون الصحيون
    • صيدلية
    • صالون تصفيف الشعر
    التجارة
    • عامل صيانة
    • الأجهزة والمعدات التقنية ودعمها
    • أنظمة الطاقة الشمسية
    • صانع أحذية
    • خدمات التنظيف
    • خدمات التكييف (HVAC)
    غير ذلك
    • منظمة غير ربحية
    • وكالة بيئية
    • تأجير لوحات إعلانية
    • تصوير
    • تأجير دراجات
    • بائع وسيط للبرمجيات
    تصفح كافة قطاعات الأعمال
  • مجتمع أودو
    تعلم
    • دروس
    • التوثيق
    • شهادات
    • التدريب
    • مدونة
    • بودكاست
    قم بتعزيز التعليم
    • برنامج تعليم
    • Scale UP! لعبة الأعمال
    • قم بزيارة أودو
    احصل على البرنامج
    • تحميل
    • قارنْ الإصدارات
    • إطلاق
    تعاون
    • جيت هاب "Github"
    • المنتدى
    • فعاليات
    • الترجمات
    • كنْ شريكاً
    • خدمات الشركاء
    • سجل مكتب المحاسبة الخاص بك
    احصل على الخدمات
    • اعثر على شريك
    • اعثر على محاسب
    • قابل أحد مرشدي الأعمال
    • خدمات التنفيذ
    • مراجع العملاء
    • الدعم
    • الترقيات
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    الحصول على عرض توضيحي
  • الأسعار
  • المساعدة

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • إدارة علاقات العملاء
  • e-Commerce
  • المحاسبة
  • المخزون
  • PoS
  • المشروع
  • MRP
All apps
يجب أن تكون مسجلاً حتى تتفاعل مع المجتمع.
كافة المنشورات الأفراد الشارات
علامات التصنيف (عرض الكل)
odoo accounting v14 pos v15
حول هذا المنتدى
يجب أن تكون مسجلاً حتى تتفاعل مع المجتمع.
كافة المنشورات الأفراد الشارات
علامات التصنيف (عرض الكل)
odoo accounting v14 pos v15
حول هذا المنتدى
المساعدة

Dynamically update cart icon after adding products from a reorder popup in Custom Odoo portal

اشتراك

تسلم الإشعارات عندما يكون هناك نشاط في هذا المنشور

لقد تم الإبلاغ عن هذا السؤال
portal
1 الرد
340 أدوات العرض
الصورة الرمزية
Saksham Khanal

I’ve built a custom portal dashboard in Odoo with a “reorder” feature. When a user clicks reorder, a popup appears showing products from a previous order, and the user can add them back to the cart.

The problem: after adding products via the popup, the cart icon in the navigation bar does not update automatically. By default, Odoo’s “Order Again” redirects users to the shop/cart page, which updates the cart icon, but I don’t want to redirect—the popup closes instead.

I want a clean way to update or rerender the cart icon dynamically after adding products from the popup, ideally using Odoo’s framework (RPC calls, JS widgets, or events) rather than direct DOM hacks.


website_sale_reorder.js

export class ReorderConfirmationDialog extends ConfirmationDialog {

static template = "website_sale.ReorderConfirmationDialog";

}

export class ReorderDialog extends Component {

static template = "website_sale.ReorderModal";

static props = {

close: Function,

orderId: Number,

accessToken: String,

};

static components = {

Dialog,

};

setup() {

this.orm = useService("orm");

this.dialogService = useService("dialog");

this.formatCurrency = formatCurrency;

onWillStart(this.onWillStartHandler.bind(this));

}

async onWillStartHandler() {

// Cart Qty should not change while the dialog is opened.

this.cartQty = parseInt(sessionStorage.getItem("website_sale_cart_quantity"));

if (!this.cartQty) {

this.cartQty = await rpc("/shop/cart/quantity");

}

// Get required information about the order

this.content = await rpc("/my/orders/reorder_modal_content", {

order_id: this.props.orderId,

access_token: this.props.accessToken,

});

// Get required information about each products

for (const product of this.content.products) {

product.debouncedLoadProductCombinationInfo = debounceFn(() => {

this.loadProductCombinationInfo(product).then(this.render.bind(this));

}, 200);

}

}

get total() {

return this.content.products.reduce((total, product) => {

if (product.add_to_cart_allowed) {

total += product.combinationInfo.price * product.qty;

}

return total;

}, 0);

}

get hasBuyableProducts() {

return this.content.products.some((product) => product.add_to_cart_allowed);

}

async loadProductCombinationInfo(product) {

for (const comboItem of product.selected_combo_items) {

comboItem.combinationInfo = await rpc("/website_sale/get_combination_info", {

product_template_id: cReorderDialogomboItem.product_template_id,

product_id: comboItem.product_id,

combination: comboItem.combination,

add_qty: comboItem.qty,

context: {

website_sale_no_images: true,

},

});

}

product.combinationInfo = await rpc("/website_sale/get_combination_info", {

product_template_id: product.product_template_id,

product_id: product.product_id,

combination: product.combination,

add_qty: product.qty,

context: {

website_sale_no_images: true,

},

});

}

getWarningForProduct(product) {

if (!product.add_to_cart_allowed) {

return _t("This product is not available for purchase.");

}

return false;

}

changeProductQty(product, newQty) {

const productNewQty = Math.max(0, newQty);

const qtyChanged = productNewQty !== product.qty;

product.qty = productNewQty;

this.render(true);

if (!qtyChanged) {

return;

}

product.debouncedLoadProductCombinationInfo();

}

onChangeProductQtyInput(ev, product) {

const newQty = parseFloat(ev.target.value) || product.qty;

this.changeProductQty(product, newQty);

}

async confirmReorder(ev) {

if (this.confirmed) {

return;

}

this.confirmed = true;

const onConfirm = async () => {

await this.addProductsToCart();

window.location = "/shop/cart";

};

if (this.cartQty) {

// Open confirmation modal

this.dialogService.add(ReorderConfirmationDialog, {

body: _t("Do you wish to clear your cart before adding products to it?"),

confirm: async () => {

await rpc("/shop/cart/clear");

await onConfirm();

},

cancel: onConfirm,

dismiss: () => {}, // Prevents fallback of 'cancel' from Confirmation Dialog

});

} else {

await onConfirm();

}

}

async addProductsToCart() {

for (const product of this.content.products) {

if (!product.add_to_cart_allowed) {

continue;

}

if (product.selected_combo_items.length) {

await rpc("/website_sale/combo_configurator/update_cart", {

combo_product_id: product.product_id,

quantity: product.qty,

selected_combo_items: product.selected_combo_items,

});

} else {

await rpc("/shop/cart/update_json", {

product_id: product.product_id,

add_qty: product.qty,

no_variant_attribute_value_ids: product.no_variant_attribute_value_ids,

product_custom_attribute_values: JSON.stringify(product.product_custom_attribute_values),

display: false,

});

}

}

}

}

This is the dialog that I have inherited and made changes to 


website_sale>templates.xml

<template id="header_cart_link" name="Header Cart Link">

<t t-nocache="The number of products is dynamic, this rendering cannot be cached."

t-nocache-_icon="_icon"

t-nocache-_text="_text"

t-nocache-_badge="_badge"

t-nocache-_badge_class="_badge_class"

t-nocache-_icon_wrap_class="_icon_wrap_class"

t-nocache-_text_class="_text_class"

t-nocache-_item_class="_item_class"

t-nocache-_link_class="_link_class">

<t t-set="website_sale_cart_quantity" t-value="request.session['website_sale_cart_quantity'] if 'website_sale_cart_quantity' in request.session else website.sale_get_order().cart_quantity or 0"/>

<t t-set="show_cart" t-value="website.has_ecommerce_access()"/>

<li t-attf-class="#{_item_class} divider d-none"/> <!-- Make sure the cart and related menus are not folded (see autohideMenu) -->

<li t-attf-class="o_wsale_my_cart #{not show_cart and 'd-none'} #{_item_class}">

<a href="/shop/cart" t-attf-class="#{_link_class}" aria-label="eCommerce cart">

<div t-attf-class="#{_icon_wrap_class}">

<i t-if="_icon" class="fa fa-shopping-cart fa-stack"/>

<sup t-attf-class="my_cart_quantity badge bg-primary #{_badge_class} #{'d-none' if (website_sale_cart_quantity == 0) else ''}" t-esc="website_sale_cart_quantity" t-att-data-order-id="request.session.get('sale_order_id', '')"/>

</div>

<span t-if="_text" t-attf-class="#{_text_class}">My Cart</span>

</a>

</li>

</t>

</template>


This is the template that I want to re-render

0
الصورة الرمزية
إهمال
الصورة الرمزية
Cybrosys Techno Solutions Pvt.Ltd
أفضل إجابة

Hi,


Odoo’s website_sale.cart public widget listens for the updateCart event.

So, after your RPC calls in addProductsToCart(), simply trigger that event using the website’s event bus:


Try the following code.


import { publicWidget } from "@web/legacy/js/public/public_widget";

import { browser } from "@web/core/browser/browser";


async addProductsToCart() {

    for (const product of this.content.products) {

        if (!product.add_to_cart_allowed) continue;


        if (product.selected_combo_items.length) {

            await rpc("/website_sale/combo_configurator/update_cart", {

                combo_product_id: product.product_id,

                quantity: product.qty,

                selected_combo_items: product.selected_combo_items,

            });

        } else {

            await rpc("/shop/cart/update_json", {

                product_id: product.product_id,

                add_qty: product.qty,

                no_variant_attribute_value_ids: product.no_variant_attribute_value_ids,

                product_custom_attribute_values: JSON.stringify(product.product_custom_attribute_values),

                display: false,

            });

        }

    }


    // Trigger cart update after products are added

    browser.trigger("updateCart");

}


Hope it helps

0
الصورة الرمزية
إهمال
هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!

أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!

تسجيل
المنشورات ذات الصلة الردود أدوات العرض النشاط
Trying to replace default “Invoices & Bills” breadcrumb in Odoo portal
portal
الصورة الرمزية
الصورة الرمزية
1
نوفمبر 25
416
is possible to add 2 filters to the web portal similar to searchbar_filters?
portal
الصورة الرمزية
الصورة الرمزية
الصورة الرمزية
2
يوليو 25
2276
How can I allow one portal user to see another portal user's information (like Sales Orders, Invoices)? تم الحل
portal
الصورة الرمزية
الصورة الرمزية
1
مايو 24
3901
Use worksheets in Odoo Portal
portal
الصورة الرمزية
الصورة الرمزية
2
فبراير 24
3025
Portail Access
portal
الصورة الرمزية
0
أبريل 23
2119
المجتمع
  • دروس
  • التوثيق
  • المنتدى
مصدر مفتوح
  • تحميل
  • جيت هاب "Github"
  • المشغل الآلي رنبوت
  • الترجمات
خدماتنا
  • استضافة أودو إس إتش
  • الدعم
  • الترقية
  • التطويرات المخصصة
  • التعليم
  • اعثر على محاسب
  • اعثر على شريك
  • كنْ شريكاً
معلومات عنا
  • شركتنا
  • أصول العلامة التجارية
  • اتصلْ بنا
  • الوظائف
  • فعاليات
  • بودكاست
  • مدونة
  • عملاء
  • قانوني • الخصوصية
  • الحماية
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

أودو هو عبارة عن مجموعة من تطبيقات الأعمال مفتوحة المصدر التي تغطي جميع احتياجات شركتك، مثل: إدارة علاقات العملاء والتجارة الإلكترونية والمحاسبة والمخزون ونقاط البيع وإدارة المشاريع وما إلى ذلك.

ما يجعل من أودو مميزاً هو هدفه بأن يكون سهل الاستخدام للغاية ومتكاملاً تمامًا في الوقت ذاته.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now