OroCommerce Forums

Covering OroCommerce topics, including community updates and company announcements.

Forums OroCommerce Adding custom order totals?

This topic contains 4 replies, has 3 voices, and was last updated by Andrey Yatsenko Andrey Yatsenko 1 month ago.

  • Creator
    Topic
  • #38440

    vincent1
    Participant

    I have a few additional fees to include to every order. They are: Handling fee, processing fee and shipping fee. I’m using setOverriddenShippingCostAmount on my Order object in order to set the custom shipping fee and it works great. However, I have no idea how to add custom fees. I’m able to easily add custom discounts, but not fees. What’s the proper way of doing this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #38451
    Andrey Yatsenko
    Andrey Yatsenko
    Moderator

    You can add a custom order subtotals, like taxes or shipping.

    It is required to create a subtotal provider, that implements SubtotalProviderInterface and register it at the container as a tagged service
    See:
    1) https://github.com/oroinc/orocommerce/blob/master/src/Oro/Bundle/TaxBundle/Provider/TaxSubtotalProvider.php#L13
    2) https://github.com/oroinc/orocommerce/blob/master/src/Oro/Bundle/TaxBundle/Resources/config/services.yml#L527-L536

    #39972

    peeush
    Participant

    Hello – I have the same requirement for adding a % of the order total as “processing fee” to each order. I have looked into Andrey’s suggested code files, but am struggling to set started on this.

    Not sure if Vincent managed to implement Andrey’s suggestions and get it working – can someone please share some sample code to apply a custom processing fee (as % of the order value) and I can use it to implement my design?

    Thanks

    #39977

    peeush
    Participant

    Hi Andrey – Can you please look at the code below and advise where I am going wrong or what have I missed?

    I have tried building a new bundle with the following folder structure:
    CustomBundle\CustomServiceFeeBundle.php
    CustomBundle\Provider\CustomServiceFeeProvider.php
    CustomBundle\Resources\config\services.yml
    CustomBundle\Resources\config\oro\bundles.yml

    Below are the files:
    services.yml

    CustomServiceFeeProvider.php

    CustomServiceFeeBundle.php and bundles.yml simply have new bundle definition.
    bundles.yml

    CustomServiceFeeBundle.php

    Unfortunately, this is not working – not sure where I am going wrong. Can you please have a look and advise?

    Thanks

    #39978
    Andrey Yatsenko
    Andrey Yatsenko
    Moderator

    Troubleshooting new bundle with the customization

    First, If you have an error, read the message, it usually contains an answer to what is wrong, if doesn’t help, try to google that message text.

    When you don’t have any errors follow the below steps:
    1) First, check that your bundle is loaded, it can be done with the built-in Symfony command

    If you are doing everything right on this step the bundle will appear in the list.

    Note: it is highly recommended to set the bundle priority to the high value so you will be able to override configuration from the previously loaded bundles.
    If doesn’t work, check https://oroinc.com/orocrm/doc/current/dev-guide/cookbook/how-to-create-new-bundle

    2) If you have registered the service, check that this service is loaded. Again there is a built-in Symfony command to do that

    where <service-name> is your service name (array key in a yaml configuration).
    If something is wrong in this step, check that the YAML file with defined service is loaded in Bundle Extension, like https://github.com/oroinc/platform/blob/master/src/Oro/Bundle/TagBundle/DependencyInjection/OroTagExtension.php#L22-L26 and validate the syntax.
    If it doesn’t work, check the documentation https://symfony.com/doc/3.4/service_container.html

Viewing 4 replies - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

You will be redirected to [title]. Would you like to continue?

Yes No