Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2 Antwoorden
1062 Weergaven
<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>
Avatar
Annuleer
Beste antwoord
<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.

Avatar
Annuleer
Auteur Beste antwoord

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

Avatar
Annuleer

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

Gerelateerde posts Antwoorden Weergaven Activiteit
1
jun. 25
517
2
apr. 25
857
2
mrt. 25
1030
0
mrt. 25
1034
2
mrt. 25
1363