Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
1071 Widoki
<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>
Awatar
Odrzuć
Najlepsza odpowiedź
<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.

Awatar
Odrzuć
Autor Najlepsza odpowiedź

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

Awatar
Odrzuć

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

Powiązane posty Odpowiedzi Widoki Czynność
1
cze 25
523
2
kwi 25
859
2
mar 25
1033
0
mar 25
1048
2
mar 25
1368