robertoroberto MemberComments: 37 Received thanks: 1 Member since: April 2017

Hi all,

I've created a plugin that should replace one of the theme TPLs with its own one. I'm trying to extend the content from change_payment.tpl inside checkout from my plugin, I have used this guide https://developers.shopware.com/developers-guide/example-plugin/ to register my templates folder creating the service and the TemplateRegistration.php file. Also checked and $injectBeforePlugins is set to true in the Theme.php file but still can't see the code.

Cleared the cache hundred million times and still nothing. Everything seems to be as it should but can't get the template overwritten.

 

change_payment.tpl inside custom/plugins/MYPLUGIN/Resources/views/frontend/checkout

{extends file="parent:frontend/checkout/change_payment.tpl"}

{block name='frontend_checkout_payment_fieldset_description'}
    <div class="method--description is--last {if $payment_mean.id != $form_data.payment} is--hidden{/if}">
        {include file="string:{$payment_mean.additionaldescription}"}
        <br>
        {if $payment_mean.isPurchasePaymentOption}
            <label for="{$payment_mean.id}">{s namespace="frontend/payment_purchase_order_option/main" name="reference_number"}Referece number{/s}</label>
            <input id="{$payment_mean.id}" name="reference_number[{$payment_mean.id}]">
        {/if}
    </div>
{/block}

Part of my services.xml for the TemplateRegistration subscriber

<!-- Register TemplateRegistration subscriber -->
        <service id="ixis_purchase_order_option.subscriber.template_registration" class="IxisPurchaseOrderOption\Subscriber\TemplateRegistration">
            <argument>%ixis_purchase_order_option.plugin_dir%</argument>
            <argument type="service" id="template"/>
            <tag name="shopware.event_subscriber"/>
        </service>

 

The TemplateRegistration.php file

<?php
/**
 * Shopware Premium Plugins
 * Copyright (c) shopware AG
 *
 * According to our dual licensing model, this plugin can be used under
 * a proprietary license as set forth in our Terms and Conditions,
 * section 2.1.2.2 (Conditions of Usage).
 *
 * The text of our proprietary license additionally can be found at and
 * in the LICENSE file you have received along with this plugin.
 *
 * This plugin is distributed in the hope that it will be useful,
 * with LIMITED WARRANTY AND LIABILITY as set forth in our
 * Terms and Conditions, sections 9 (Warranty) and 10 (Liability).
 *
 * "Shopware" is a registered trademark of shopware AG.
 * The licensing of the plugin does not imply a trademark license.
 * Therefore any rights, title and interest in our trademarks
 * remain entirely with us.
 */

namespace IxisPurchaseOrderOption\Subscriber;

use Enlight\Event\SubscriberInterface;
use Enlight_Template_Manager as TemplateManager;

class TemplateRegistration implements SubscriberInterface
{
    /**
     * @var string
     */
    private $pluginPath;

    /**
     * @var TemplateManager
     */
    private $templateManager;

    /**
     * @param string          $pluginPath
     * @param TemplateManager $templateManager
     */
    public function __construct($pluginPath, TemplateManager $templateManager)
    {
        $this->pluginPath = $pluginPath;
        $this->templateManager = $templateManager;
    }

    /**
     * {@inheritdoc}
     */
    public static function getSubscribedEvents()
    {
        return [
            'Enlight_Controller_Action_PreDispatch' => 'onPreDispatch',
        ];
    }

    /**
     * Registers the template directory globally for each request
     */
    public function onPreDispatch()
    {
        $this->templateManager->addTemplateDir($this->pluginPath . '/Resources/views/');
    }
}

 

Will appreciate any help!

Answers

  • shopnoob85shopnoob85 MemberComments: 2 Received thanks: 0 Member since: August 14

    Same problem here. I'am not able to overwrite any block on any template and i dont know why. 

    But you know what, SwagSloganOfTheDay or SwasShoeSize will not work, too.

    So currentyl iam angry because i dont know why. So please Shopware help us.

    By the way a use a local shopware installation via xampp

  • Moritz NaczenskiMoritz Naczenski AdministratorsComments: 7594 Received thanks: 2239 Member since: September 2013

    The template inheritance has some issues on windows. Without a proper linux based development environment, you won‘t get it working properly.

  • shopnoob85shopnoob85 MemberComments: 2 Received thanks: 0 Member since: August 14

    Ok, thanks for the information but how can i run a local shopware shop under windows without issues with the template inheritance? Is there a way or do i need to install shopware via vm or docker or should i install a linux on my pc?

Sign In or Register to comment.