Jump to content
tuk66

[MODULE] M4 PDF Extensions (with online editor)

Recommended Posts

I assume that after the M4PDF module has been disabled, the error will disappear.

Can you check mutual position these two modules in the displayPDFInvoice hook (Design > Positions)? Will changing the order of the modules in this hook solve the error?

Share this post


Link to post
Share on other sites

I haven't found a compatibility issue with the PayPal PLUS module, but it seems that there are two different ways to generate the PDF invoice, which causes conflict.

Try this hack. Replace this block in the /config/smartyadmin.config.inc.php file

smartyRegisterFunction($smarty, 'function', 'toolsConvertPrice', 'toolsConvertPrice');
smartyRegisterFunction($smarty, 'function', 'convertPrice', array('Product', 'convertPrice'));
smartyRegisterFunction($smarty, 'function', 'convertPriceWithCurrency', array('Product', 'convertPriceWithCurrency'));
smartyRegisterFunction($smarty, 'function', 'displayWtPrice', array('Product', 'displayWtPrice'));
smartyRegisterFunction($smarty, 'function', 'displayWtPriceWithCurrency', array('Product', 'displayWtPriceWithCurrency'));
smartyRegisterFunction($smarty, 'function', 'displayPrice', array('Tools', 'displayPriceSmarty'));
smartyRegisterFunction($smarty, 'modifier', 'convertAndFormatPrice', array('Product', 'convertAndFormatPrice')); // used twice
smartyRegisterFunction($smarty, 'function', 'getAdminToken', array('Tools', 'getAdminTokenLiteSmarty'));
smartyRegisterFunction($smarty, 'function', 'displayAddressDetail', array('AddressFormat', 'generateAddressSmarty'));
smartyRegisterFunction($smarty, 'function', 'getWidthSize', array('Image', 'getWidth'));
smartyRegisterFunction($smarty, 'function', 'getHeightSize', array('Image', 'getHeight'));
smartyRegisterFunction($smarty, 'function', 'addJsDef', array('Media', 'addJsDef'));
smartyRegisterFunction($smarty, 'block', 'addJsDefL', array('Media', 'addJsDefL'));
smartyRegisterFunction($smarty, 'modifier', 'secureReferrer', array('Tools', 'secureReferrer'));

with

smartyRegisterFunction($smarty, 'function', 'toolsConvertPrice', 'toolsConvertPrice');
if (!isset($smarty->registered_plugins['function']['convertPrice'])) {
    smartyRegisterFunction($smarty, 'function', 'convertPrice', array('Product', 'convertPrice'));
}
if (!isset($smarty->registered_plugins['function']['convertPriceWithCurrency'])) {
    smartyRegisterFunction($smarty, 'function', 'convertPriceWithCurrency', array('Product', 'convertPriceWithCurrency'));
}
if (!isset($smarty->registered_plugins['function']['displayWtPrice'])) {
    smartyRegisterFunction($smarty, 'function', 'displayWtPrice', array('Product', 'displayWtPrice'));
}
if (!isset($smarty->registered_plugins['function']['displayWtPriceWithCurrency'])) {
    smartyRegisterFunction($smarty, 'function', 'displayWtPriceWithCurrency', array('Product', 'displayWtPriceWithCurrency'));
}
if (!isset($smarty->registered_plugins['function']['displayPrice'])) {
    smartyRegisterFunction($smarty, 'function', 'displayPrice', array('Tools', 'displayPriceSmarty'));
}
smartyRegisterFunction($smarty, 'modifier', 'convertAndFormatPrice', array('Product', 'convertAndFormatPrice')); // used twice
smartyRegisterFunction($smarty, 'function', 'getAdminToken', array('Tools', 'getAdminTokenLiteSmarty'));
smartyRegisterFunction($smarty, 'function', 'displayAddressDetail', array('AddressFormat', 'generateAddressSmarty'));
smartyRegisterFunction($smarty, 'function', 'getWidthSize', array('Image', 'getWidth'));
smartyRegisterFunction($smarty, 'function', 'getHeightSize', array('Image', 'getHeight'));
smartyRegisterFunction($smarty, 'function', 'addJsDef', array('Media', 'addJsDef'));
smartyRegisterFunction($smarty, 'block', 'addJsDefL', array('Media', 'addJsDefL'));
smartyRegisterFunction($smarty, 'modifier', 'secureReferrer', array('Tools', 'secureReferrer'));

 

Share this post


Link to post
Share on other sites

I tried this, but unfortunately no luck. The error remains exactly the same. (Did I clearing a cache of some sort? Did clear it in the backend only)

I also realized that there is a similiar problem in PS 1.6.1 with Paypal Plus aswell. There it happens, that on the order confirmation page all the page headers aren't loaded. Only the content text appears. Server log says:

AH01071: Got error 'PHP message: PHP Warning: A non-numeric value encountered in [...]/cache/smarty/compile/df/67/19/df67190c92bd2c1c44c5a227b1e2af904e7b0d08.file.m4_invoice_2_bd_freetext+.tpl.php on line 446
PHP message: PHP Fatal error: Uncaught Error: Call to a member function displayPriceSmarty() on string in [...]/cache/smarty/compile/37/c2/f6/37c2f61e59cf6410dabd086a194309f5f721cd6f.file.order-confirmation.tpl.php:136
Stack trace:
#0 [...]/tools/smarty/sysplugins/smarty_internal_templatebase.php(188): content_5dfcc6afa52399_89826546(Object(Smarty_Custom_Template))
#1 [...]/classes/SmartyCustom.php(110): Smarty_Internal_TemplateBase->fetch('/var/www/vhosts...', NULL, NULL, Object(SmartyCustom), false, true, false)
#2 [...]/classes/controller/FrontController.php(713): SmartyCustomCore->fetch('/var/www/vhosts...')
#3 [...]/classes/controller/Controller.php(209): FrontControllerCore->display()\n#4 [...]...
', referer: [...]/module/paypalplus/execute?id_cart=131648&paymentId=PAYID-LYDCF6Y8U6334757M5935827&token=EC-8AG798295A471231A&PayerID=C5T48JQZ4VBZ4

 

Share this post


Link to post
Share on other sites

I must confirm that there is an issue when this module works next to another module which creates PDF output. I know two such modules: PayPal PLUS and Terms of Sale Send. I'm working on a solution and the fix will be available soon.

Anyway, the mentioned temporary solution should also work. Have you used the exclamation marks in:

if (!isset($smarty->registered_plugins

 

Share this post


Link to post
Share on other sites

The new version of the module is available at www.presta-addons.com. All upgrades are FREE for life.

CHANGELOG


 v3.1.3 (2020-01-06)

- Optimized memory usage
- Added Slovak translation
- Fixed bug caused by re-registering Smarty Modifier when order is completed (PrestaShop 1.7 and another module with PDF output is active)
- Fixed bug when using Debug Template (PrestaShop 1.7.0.0 to 1.7.3.4)
- Fixed the template list appearance (only when Ap PageBuilder is installed)

  • Like 1

Share this post


Link to post
Share on other sites
On 5/12/2014 at 10:50 AM, tuk66 said:

HOW TO show product features in invoice

 

Insert the code below inside the order_detail loop ({section name=detail loop=$order[orders].order_detail}) to display product features. This example shows using static functions inside

On 5/12/2014 at 10:50 AM, tuk66 said:

HOW TO show product features in invoice

 

Insert the code below inside the order_detail loop ({section name=detail loop=$order[orders].order_detail}) to display product features. This example shows using static functions inside a template.



{assign var="features" value=Product::getFrontFeaturesStatic($conf.pdf_id_lang, $order[orders].order_detail[detail].product_id)}
{* {$features|@debug_print_var} *}
{section name=feature loop=$features}
    {* use the first or second style *}
    {$features[feature].value}{if !$smarty.section.feature.last} x {/if}
    {* {$features[feature].name}: {$features[feature].value}{if !$smarty.section.feature.last}, {/if} *}
{/section}

.
To display only one feature use (set your feature name instead of Fill_in_name_of_feature string):



{assign var="features" value=Product::getFrontFeaturesStatic($conf.pdf_id_lang, $order[orders].order_detail[detail].product_id)}
{section name=feature loop=$features}
    {if $features[feature].name == 'Fill_in_name_of_feature'}
        {$features[feature].value|escape:'htmlall':'UTF-8'}
    {/if}
{/section}

a template.


{assign var="features" value=Product::getFrontFeaturesStatic($conf.pdf_id_lang, $order[orders].order_detail[detail].product_id)}
{* {$features|@debug_print_var} *}
{section name=feature loop=$features}
    {* use the first or second style *}
    {$features[feature].value}{if !$smarty.section.feature.last} x {/if}
    {* {$features[feature].name}: {$features[feature].value}{if !$smarty.section.feature.last}, {/if} *}
{/section}

.
To display only one feature use (set your feature name instead of Fill_in_name_of_feature string):


{assign var="features" value=Product::getFrontFeaturesStatic($conf.pdf_id_lang, $order[orders].order_detail[detail].product_id)}
{section name=feature loop=$features}
    {if $features[feature].name == 'Fill_in_name_of_feature'}
        {$features[feature].value|escape:'htmlall':'UTF-8'}
    {/if}
{/section}

Hi.
I try to make only ONE feature visible on invoice template but the example in the forum does not work. How can I revise the code that is available for all features?

    <!-- start product features block -->
                
                    {if !empty($r_order.product_feature)}
                        {foreach from=$r_order.product_feature[$order_detail.product_id]|@sortby:"name" item=product_feature name=product_feature}
                            <br />&nbsp;&nbsp;&nbsp;&nbsp;<span class="smaller">{$product_feature.name|escape:'htmlall':'UTF-8'}: {$product_feature.value|escape:'htmlall':'UTF-8'}</span>
                        {/foreach}
                    {/if}
                    <!-- end product features block -->

I´m running 1.7.6 and the latest version of your module.

Share this post


Link to post
Share on other sites

Try this snippet if you are using version 3.* of the module (I must adapt the How-Tos for these versions):

{assign var="features" value=Product::getFrontFeaturesStatic($conf.pdf_id_lang, $order_detail.product_id)}
{section name=feature loop=$features}
    {if $features[feature].name == 'Fill_in_name_of_feature'}
        {$features[feature].value|escape:'htmlall':'UTF-8'}
    {/if}
{/section}

 

  • Like 1

Share this post


Link to post
Share on other sites

Hi, I like this module verry much ! Just one thing, when you are on product list, and you will display catalog.tpl with the CUSTOMER price ( With the discount of the group customer ), wich code have I to add on it ?!

For the moment, the price is always the basic price.

Thanks a lot for answer,


Steven D.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More