Jump to content

[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
  • Replies 536
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Then add a condition inside the {section}. {section name=features loop=$product[products].product_feature}     {if $product[products].product_feature[features].name == 'Fill_in_name_of_feature'}   

Some modules use messages in their own way, so I prepared a fix for the next version (2.3.0). Send me PM if you need it right now.

Look at Smarty documentation   {foreach} http://www.smarty.net/docs/en/language.function.foreach   {assign} http://www.smarty.net/docs/en/language.function.assign.tpl

Posted Images

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
  • 4 weeks later...

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
  • 2 weeks later...

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
  • 5 weeks later...
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
  • 2 weeks later...

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

The current price depends on the customer who prints the catalog and on the cart as well. The price is calculated from these values (and more).

I will prepare an upgrade which will provide these data for templates so you can use methods like Product::getPriceStatic() to get the current price.

Share this post


Link to post
Share on other sites
  • 8 months later...

I'm glad to introduce a new version of this module at www.presta-addons.comAll upgrades are FREE for life.

CHANGELOG

v3.2.0 (2020-11-26)

- All features are now compatible with PrestaShop 1.7.7 and PHP 7.3
- Support for $HOOK_DISPLAY_PDF Smarty variable (all displayPDF* hooks)
- Introducing 3 independent style sheets that make it easy to change the look of your output
- Removed CmsController and CategoryController overrides without changing functionality
- Tooltip images updated to PrestaShop 1.7 look
- Checked all templates, fixed some and improved most ones
- Added "how to do" instructions for new features offered by the module - Settings tab
- Preset default templates on the Settings tab after installation
- Fixed doubled customization data in some cases

Edited by tuk66 (see edit history)

Share this post


Link to post
Share on other sites

Hello  tuk66 ! I Love your module, my invoices are great now !

Question,  I would like to use your tax report template, and tax report (grouped by days).

However, I would like a tax on product column and a tax on delivery cost column. Is that possible ?

For tax report (grouped by days) template. Do you think it is possible to also sort by country?

Thanks a lot.

Share this post


Link to post
Share on other sites

Hi,

I'm not sure if it is easily possible to have separate product and delivery cost columns. The base and tax amounts are taken from $r_order.price_breakdown.taxList and there are no 'product' and 'delivery' parts in this tax list array.

As of the Tax report (grouped by days), do you mean to sort the table by country instead of date or change the order of the tax columns?

Share this post


Link to post
Share on other sites

It looks easy. Try to change

{foreach from=$order|@sortby:"#invoice_date" item=r_order name=r_order}

to

{foreach from=$order|@sortby:"#invoice_date,address_invoice.country.iso_code" item=r_order name=r_order}

You can also try to use name instead of iso_code.

Share this post


Link to post
Share on other sites

It looks easy. Try to change

{foreach from=$order|@sortby:"#invoice_date" item=r_order name=r_order}

to

{foreach from=$order|@sortby:"#invoice_date,address_invoice.country.iso_code" item=r_order name=r_order}

You can also try to use name instead of iso_code.

Share this post


Link to post
Share on other sites
  • 4 weeks later...

Hi, does anyone have templates for CN22 and CN23 customs documents for M4pdf? Since brexit I need to include these and didn't want to invent the wheel twice 🙂

Thanks!

Share this post


Link to post
Share on other sites

Thanks, I've imported them and they print the form data but not the form. Is there one that does that too? (Or is one only allowed to use the official forms)?

Share this post


Link to post
Share on other sites
  • 4 weeks later...

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

CHANGELOG

v3.2.2 (2021-02-11)

- Fixed a rare Fatal error: Uncaught ...ServiceNotFoundException: The service "theme_manager" has a dependency on a non-existent service "employee"
- Fixed image background for the Catalog in grid, with categories template (m4_catalog_grid_category.tpl)
- Fixed occasional sending of the original invoice by email

Share this post


Link to post
Share on other sites
  • 2 months later...

Hi, I'm on prestashop 1.6.1.24 and i'd like to add a link of the products when i export the catalogue.

 

I've add :

{$link->getProductLink($product)}

 

it prints only: http://xxx/index.php?controller=product&id_lang=1

but it doesn't work. Can anyone help me ?

 

Share this post


Link to post
Share on other sites

You can find it in the "Catalog sorted by category organized in grid, price with tax" template (m4_catalog_sorted_category_tax.tpl).

<a href="{$link->getProductLink($r_product.id_product, null, $r_product.id_category_default, $r_product.ean13, $conf.pdf_id_lang)}" target=_blank>{l s='product details' mod='m4pdf'}</a>

 

Share this post


Link to post
Share on other sites
  • 2 weeks later...

Hey, 

i need add to deliveryslip column with supplier for product. How do it? I want use original delivery template with barcode.

Thank you, 

Daniel 

Share this post


Link to post
Share on other sites
  • 2 weeks later...

Hola,

He instalado el modulo y al intentar modificar una de las plantillas existentes o intentar crear una nueva me da error y no deja hacerlo.

Alguna idea de por que puede pasar?

 

Gracias1070248306_M4PDF.thumb.png.aff609ef25ddb40eeeae31d74f0e25f7.png

Share this post


Link to post
Share on other sites

I ask anyone who has a technical problem or question to install the module to contact me at the place where the module was purchased. Either at https://www.presta-addons.com or at PrestaShop Addons Message board.

There are things that cannot be solved here on the forum.

 

Share this post


Link to post
Share on other sites
Posted (edited)

Hi tuk66,

I just updated your module and the extra options in the back office have disappeared (even when activated).

Do you know how it can be displayed as this is a really helpful option.

I am using 1.6.1.24

Edited by kingcrab (see edit history)

Share this post


Link to post
Share on other sites
Posted (edited)

I think I understood the problem. I am using php5.6.40

Your module worked correctly on php7.1.33 I use for a test website.

 

MY BAD, I still get an error, I am sending you a message through addons.

Edited by kingcrab (see edit history)

Share this post


Link to post
Share on other sites

I found the problem, it comes from the missing translations of the module. If they are not correctly set up, the module won't work correctly except for English.

Share this post


Link to post
Share on other sites

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

CHANGELOG

v3.2.3 (2021-05-20)

- Fixed selection of correct template for invoice, credit clip and order return in some cases (PrestaShop 1.7.7 only)
- Fixed using the selected language in the language selection block in the administration in some cases (PrestaShop 1.7.7 only)
- Fixed displaying languages in the Extra Options in Back Office

Share this post


Link to post
Share on other sites

How can we add the stock_available in the supply order tpl? Samefor the product pictures.

I tried but it's not working:

{$supply_order_detail.product.stock_available.quantity}

Share this post


Link to post
Share on other sites
  • 2 weeks later...

i have a purchased module of 

M4 extensiones PDF

(addons.prestashop)

But i update to prestashop 1.7 and the prices appears without tax

i have this code in the .tpl

 

    <div class="w100 zero clear align-center">
            {assign var="tax" value=$products.default_country_tax.rate/100+1}
            {assign var="price_wt" value=$products.price*$tax}
            <span class="normal">{l s='Precio:'}</span> {displayPrice price=$products.price currency=$conf.currency_current}
        </div>

 

how can apply 4% TAX ?

 

thanks

Share this post


Link to post
Share on other sites

@kingcrab
@pegasus6464

Use the "~ Debug template" to see the data. You can find answers, like why is $products.default_country_tax.rate zero, because the the price should be tax including.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

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