cancel
Showing results for 
Search instead for 
Did you mean: 

Get grand total by id using DI

Re: Get grand total by id using DI

Hello @infonectar9054 

 

Kindly refer below tutorial:
Custom module creation 

link 2 

 

 

Problem solved? Click Accept as Solution!

Re: Get grand total by id using DI

Hello @infonectar9054 

 

Kindly refer below link:
https://magento.stackexchange.com/questions/121364/magento-2-how-to-call-any-block-function-in-phtml 

Problem solved? Click Accept as Solution!

Re: Get grand total by id using DI

Hi @Bhanu Periwal 

I did it but the details of success.phtml is changed when I call the block also the function not appear in view page source.

But if I delete the block from phtml it's work fine !

Re: Get grand total by id using DI

Hi @Bhanu Periwal 

This is my block file :

<?php
namespace Nectar\Google\Block;
use Magento\Framework\View\Element\Template;

class Success extends Template
{
    /**
     * @return int
     */
    public function getGrandTotal()
    {
        $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $orders = $objectManager->create('Magento\Sales\Model\Order')->load($block->getOrderId());

        return $orders->getGrandTotal();
    }
}

Re: Get grand total by id using DI

Hello @infonectar9054 

 

In your layout page, declare relation of block and phtml file as well, refer below code:

    <?xml version="1.0"?>
    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <body>
            <referenceContainer name="content">
                <block class="Cloudways\Newmodule\Block\Newmodule" name="cloudways_newmodule" template="newmodule.phtml"></block>
            </referenceContainer>
        </body>
    </page>
Problem solved? Click Accept as Solution!

Re: Get grand total by id using DI

Hello @infonectar9054 

 

I think you should take help of developer in this case.

Problem solved? Click Accept as Solution!

Re: Get grand total by id using DI

Hi @Bhanu Periwal 

Okay how I can contact with developer. Do you have a list or website ?

Because in my country we don't have Magento developers.