Forums › Forums › OroCommerce › Quick order form: how to change default button?
This topic contains 14 replies, has 2 voices, and was last updated by Mauro Chojrin 4 years, 4 months ago.
Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.
- CreatorTopic
- September 12, 2019 at 6:46 am #40417
Hi:
I’m trying to change the default button on the quick order form from “Add to…” (Shopping list) to “Create order”.
Is there a way to do this without modifying the code?
Thanks!
- CreatorTopic
- AuthorReplies
- September 13, 2019 at 8:11 am #40428
Hi Mauro,
Maybe I understand you wrong, but there is no default button on a quick order form, and the shopping list button just highlighted with a CSS class “btn–info”, nothing more.Is there a way to do this without modifying the code?
No,
If you want to change the style of the buttons to remove btn–info class from the shopping list button and add it to the create order button from the code – you can override the template that renders “add to shopping list” button
vendor/oro/commerce/src/Oro/Bundle/ShoppingListBundle/Resources/views/Action/buttons.html.twig
and update frontend_options of start_from_quickorderform transition in a checkout workflow.September 13, 2019 at 12:11 pm #40434Got it. Thanks for the clarification :)
In order to override that template, should I create a new Bundle?
October 30, 2019 at 6:34 am #40783Hi Andrey:
I’m working on this again and I’m not exactly sure how to go about it.
I have two main issues:
1 – Where should the new template be located? Currently I placed it at src/Leeway/Bundle/ThemeBundle/templates/Bundles/ShoppingListBundle/Resources/views/Action/buttons.html.twig is this correct?
2 – I don’t fully understand where I should make the css changeHere’s the code of the original template:
XHTML123456789101112131415161718192021222324252627282930313233343536{% import 'OroShoppingListBundle:ShoppingList/Frontend:buttons.html.twig' as buttons %}{% set buttonOptions = {dataUrl: false,dataAttributes: {}} %}{% set buttonsOptions = {new: buttonOptions,current: buttonOptions,existing: buttonOptions,singleButtonACss : 'btn--info',shoppingLists: actionData.shoppingLists,componentModule: params.buttonOptions.page_component_module|default('oroshoppinglist/js/app/views/product-quick-add-to-shopping-list-view'),componentOptions: {'quickAddComponentPrefix': 'quick-add'}|merge(params.buttonOptions.page_component_options|default({}))} %}<div class="widget-content btn-group"><div class="mass-action-controls">{% import 'OroUIBundle::macros.html.twig' as UI %}{{ UI.pinnedDropdownButton({'html': buttons.getButtonsHtml(buttonsOptions),'mobileEnabled': true,'dataAttributes': {'layout': 'deferred-initialize'},'options': {'widgetModule': 'oroproduct/js/content-processor/product-add-to-dropdown-button','widgetName': 'productAddToDropdownButtonProcessor','truncateLength': 25}}) }}</div></div>Could I get some more detail? Thanks!
October 30, 2019 at 8:30 am #40785Hi Mauro,
See how to override the twig templates article in this article: https://doc.oroinc.com/frontend/back-office/templates/#override-twig-templates.
For the second question see the CSS guide https://doc.oroinc.com/frontend/back-office/css/October 31, 2019 at 6:29 am #40798Thanks Andrey!
So far I got to confirm the correct location of the new template:
PHP1src/Resources/OroShoppingListBundle/views/Action/buttons.html.twigI have to say this mapping has always been somewhat cumbersome for me (In Symonfy in general, not oro in particular)… I’m still trying to figure out the css part, but I’m getting closer :)
October 31, 2019 at 8:04 am #40799So, after digging a lot into the code (grepping files here and there) I got to this file: vendor/oro/commerce/src/Oro/Bundle/CheckoutBundle/Resources/config/oro/workflows/includes/base_transitions.yml where there’s a section I believe should be responsible for the rendering of the “Create Order” button:
YAML1234567start_from_quickorderform:is_start: trueis_unavailable_hidden: truetransition_definition: start_from_quickorderform_definitionfrontend_options:icon: fa-clipboardclass: 'btn--info'So I added the last line to try and see what happened, I cleared the cache… but nothing changed :(
I did succeed in removing the btn–info class from the “Add to Quick Order” button, but I think the other button is somewhere else…
November 1, 2019 at 7:38 am #40803After updating the workflow configuration, it is required to reload its state at the database with the command
Shell1php bin/console oro:workflow:definitions:loadNovember 14, 2019 at 10:19 am #40881Thanks Andrey:
I did this and it works. The problem I have is that I made the change directly within the vendor directory and, as I suspected, once I deployed a new minor version everything went back to the way it was and I had to re-apply the change…
How can I make this change permanent?
Thanks!
November 15, 2019 at 1:27 am #40887To customize the workflow, we recommend to clone it:
https://doc.oroinc.com/backend/entities-data-management/workflows/#workflows-actions-cloneNovember 15, 2019 at 9:42 am #40901Thanks. I followed that guide and my new workflow is showing in the workflow configuration panel but I don’t see the change.
I tried de-activating the Alternative Checkout workflow but it didn’t seem to make a difference.
I cleared my cache and that didn’t work either…
Am I missing something?
November 21, 2019 at 3:33 am #40957I finally understood my mistake: I was following the instructions too literally :)
I cloned the alternativecheckout workflow when what I actually needed to clone was b2b_flow_checkout.
Once I did that the change was applied.
The problem I’m having now is with the translation of the label… for some reason I don’t understand it’s not taking it.
Even though I did create a translation file I still see the label like this:
November 21, 2019 at 4:49 am #40959Hi Mauro,
There is the documentation on it
https://doc.oroinc.com/backend/entities-data-management/workflows/#translationsNovember 21, 2019 at 2:44 pm #40961Hi Andrey:
Thanks, sorry to bug you.
I went through the documentation you pointed me to and I thought the problem was that I was using “en_US” as locale instead of “en” (Which is the one I used when dumping, so the resulting file is src/Leeway/Bundle/ThemeBundle/Resources/translations/workflows.en.yml).
I issued the following commands:
Shell12sudo -u nginx bin/console oro:translation:load --env=prod -l ensudo -u nginx php bin/console oro:workflow:definitions:load --env=prodBut when I go to the translations panel I don’t see any translations under any key that contains
b2b_flow_checkout_cloned.What am I doing something wrong?
Thanks
November 25, 2019 at 10:52 am #40982I just deployed my new version to production and it worked.
I think I might have had an issue with the name of my cloned workflow and my translation file… anyway, thanks for your help!
- AuthorReplies
The forum ‘OroCommerce’ is closed to new topics and replies.