0

I tried moving the Stored Payment Methods Block of the module vault (Original at) (vendor/magento/module-vault/view/frontend/templates/cards_list.phtml) to the Account Information Block of the module customer. (Original at) (vendor/magento/module-customer/view/frontend/templates/account/dashboard/info.phtml)

In customer_account_index.xml I did:

<referenceBlock name="customer_account_dashboard_info">
  <block class="Magento\Vault\Block\Customer\CreditCards" name="vault.cards.list" cacheable="false" template="Magento_Vault::cards_list.phtml" />
</referenceBlock>

And then in info.phtml:

 <!-- Stored Payment Method Code -->
 <?php echo $block->getChildHtml('vault.cards.list'); ?>

but by doing this only its header is displayed and the card details aren't. I'm not sure what is wrong. Below I have attached the Screenshot.

For reference, In cards_list.phtml file the code responsible to render the body of the card details is

<tbody>
   <?php
   foreach ($tokens as $token) {
     echo $block->renderTokenHtml($token);
    }
   ?>
 </tbody>

I've tried different methods of moving but still, it isn't showing up. I've also moved other components this way and it has worked for me in the past.

What I would've to do for the card details to also show up.

The file responsible to render card details is at vendor/magento/module-vault/view/frontend/templates/customer_account/credit_card.phtml

enter image description here

enter image description here

1 Answer 1

1

The block vault.cards.list is responsible for rendering cards list is located in the vendor/magento/module-vault/view/frontend/layout/vault_cards_listaction.xml

The template responsible for rendering card details is located in the vendor/magento/module-vault/view/frontend/templates/customer_account/credit_card.phtml file.
In the Magento default, this template belongs to

  • the paybraintree.card.renderer block, which is defined in the vendor/paypal/module-braintree-core/view/frontend/layout/vault_cards_listaction.xml file in the Paypal Braintree Core module.
<referenceBlock name="vault.cards.list">
    <block class="PayPal\Braintree\Block\Customer\CardRenderer" name="braintree.card.renderer" template="Magento_Vault::customer_account/credit_card.phtml"/>
</referenceBlock>
  • the payflow.card.renderer block, which is defined in the vendor/magento/module-paypal/view/frontend/layout/vault_cards_listaction.xml file in the Paypal module.
<referenceBlock name="vault.cards.list">
    <block class="Magento\Paypal\Block\Payflow\Customer\CardRenderer" name="payflow.card.renderer" template="Magento_Vault::customer_account/credit_card.phtml"/>
</referenceBlock>

As shown, the braintree.card.renderer and the payflow.card.renderer blocks reference the vault.cards.list block to render their content within the vault.cards.list block.

Therefore, to add the Magento_Vault::customer_account/credit_card.phtml template to your vault.cards.list block in the Account information page, you have to define the braintree.card.renderer and the payflow.card.renderer blocks within the vault.cards.list block in your account index layout (customer_account_index.xml).

Your vault.cards.list block should be like this:

<block class="Magento\Vault\Block\Customer\CreditCards" name="vault.cards.list" cacheable="false" template="Magento_Vault::cards_list.phtml">
    <block class="Magento\Paypal\Block\Payflow\Customer\CardRenderer" name="payflow.card.renderer" template="Magento_Vault::customer_account/credit_card.phtml"/>
    <block class="PayPal\Braintree\Block\Customer\CardRenderer" name="braintree.card.renderer" template="Magento_Vault::customer_account/credit_card.phtml"/>
</block>

In case you using a third-party extension that has a block reference the vault.cards.list block to render its content within the vault.cards.list block:
<module dir>/view/frontend/layout/vault_cards_listaction.xml:

<referenceBlock name="vault.cards.list">
    <block class="Magetu\Payment\Block\Customer\CardRenderer" name="magetu.card.renderer" template="Magetu_Payment::vault/customer_account/credit_card.phtml"/>
</referenceBlock>

You can do the same like I mentioned for the Paypal and Paypal Braintree Core modules. Your vault.cards.list block should be like this:

<block class="Magento\Vault\Block\Customer\CreditCards" name="vault.cards.list" cacheable="false" template="Magento_Vault::cards_list.phtml">
    <block class="Magento\Paypal\Block\Payflow\Customer\CardRenderer" name="payflow.card.renderer" template="Magento_Vault::customer_account/credit_card.phtml"/>
    <block class="PayPal\Braintree\Block\Customer\CardRenderer" name="braintree.card.renderer" template="Magento_Vault::customer_account/credit_card.phtml"/>
    <block class="Magetu\Payment\Block\Customer\CardRenderer" name="magetu.card.renderer" template="Magetu_Payment::vault/customer_account/credit_card.phtml"/>
</block>
7
  • I tried this but this doesn't work either. Commented Aug 18, 2023 at 14:32
  • There is another block references the vault.cards.list in the Braintree module. Could you add the following block inside the vault.cards.list block I provided in my answer? <block class="PayPal\Braintree\Block\Customer\CardRenderer" name="braintree.card.renderer" template="Magento_Vault::customer_account/credit_card.phtml"/>
    – Tu Van
    Commented Aug 18, 2023 at 15:16
  • nope that didn't work either Commented Aug 18, 2023 at 15:25
  • I haven't setup the payment method that supports Store Payment Methods, so I'll try to write the instructions here to help you debug. Which payment method you are using? Please add this code var_dump(get_class($block));die; on line 11 in the vendor/magento/module-vault/view/frontend/templates/customer_account/credit_card.phtml file and then visit the Stored Payment Methods page to get the output? It will help me know which block is rendering credit_card.phtml template file.
    – Tu Van
    Commented Aug 18, 2023 at 15:46
  • And please replace the foreach code in the vendor/magento/module-vault/view/frontend/templates/cards_list.phtml file with the following code foreach ($tokens as $token) { var_dump($token); } die;, and visit the Account information page to get output and paste it in somewhere like paste.org and share me the link to debug.
    – Tu Van
    Commented Aug 18, 2023 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.