Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
959 มุมมอง
<a role="button" name="website_sale_main_button" class=" btn btn-primary  w-100" href="/shop/checkout?try_skip_step=true">
                        Checkout
                        <i class="fa fa-angle-right ms-2 fw-light" data-oe-model="ir.ui.view" data-oe-id="1996" data-oe-field="arch" data-oe-xpath="/t[1]/div[1]/t[1]/t[2]/a[1]/i[1]"></i>
                    </a>

I have changed the flow of my e-commerce to force users to register for an appointment first before they pay.  Everything works very well.  I only need to change the text on the button from Checkout to Book Appointment.

I have tried this and it throws an error, that the button does not exist.  How do I correctly reference this button?  Thank you for the assistance.

<template id="custom_checkout_button_text" inherit_id="website_sale.checkout" name="Custom Checkout Button Text">
    <xpath expr="//t[@t-out=\"step_specific_values['main_button']\"]" position="replace">
        <t>Book Appointment</t>
    </xpath>
</template>
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด
<t t-out="step_specific_values['main_button']"/>

is defined in 

<template id="navigation_buttons" ... />


<a role="button" name="website_sale_main_button" ... />

is defined in

<template id="extra_info" ... />

and

<template id="navigation_buttons" ... />


Now, none of these actually hold a string 'Checkout'. Instead, Odoo uses a list of tuples that seems rather complex at first sight to generate the buttons for each sidebar, grouped in (the actual checkout) steps.

So, while you theoretically could just replace <t t-out="step_specific_values['main_button']"/> in website_sale.step_specific_values (not website_sale.checkout!) you should rather inherit the website model and change the behavior of _get_checkout_step_list() like this:

from odoo import models
from odoo.tools.translate import LazyTranslate
_lt = LazyTranslate(__name__)


class Website(models.Model):
_inherit = 'website'

def _get_checkout_step_list(self):
steps = super()._get_checkout_step_list()
# You may want to adjust the conditions to more precisely limit the
# string replacement to website_sale.cart
for _, data in steps:
if 'main_button' in data and str(data['main_button']) == 'Checkout':
data['main_button'] = _lt('Book Appointment')
return steps

Else, you're potentially overriding the labels of other steps too.

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

This has resolved my question. It has worked! Thank you

อวตาร
ละทิ้ง

Great! I would appreciate you marking my answer as working then :)

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
มิ.ย. 25
438
2
เม.ย. 25
767
2
มี.ค. 25
918
0
มี.ค. 25
944
2
มี.ค. 25
1284