Prestashop 1.7.6.9 display default category_name into email and backoffice order - prestashop

I need to show:
"default category name" of the purchased products into email template
order_conf "default category name" of the purchased products into
backoffice > single order (where at the moment it shows product_name + reference)
BO > orders > order > purchased product
Would you give me some indication on the files to be modified to show the category name (default_category) of the purchased products?
I have searched around the web but I can't find any solution / instructions to do this
Thanks to anyone who will be able to help me
Prestashop 1.7.6.9

To show info in back office order detail you can use hook displayAdminOrderLeft.
For more info look at https://devdocs.prestashop.com/1.7/modules/concepts/hooks/list-of-hooks/
For mail you must change order_conf.html in mails directory.
To put extra data in template vars you can use actionEmailAddBeforeContent hook.

Thankyou Fran Cerezo for the indication to investigate.
To show Default Category name into hook "displayAdminOrderLeft", i opened
/admin123456/themes/default/template/controllers/orders/_product_line.tpl file
So i added
{if isset($product.id_category_default)}
{assign var='catname' value=Category::getCategoryInformations(array($product.id_category_default))}
{$catname[$product.id_category_default].name}
{/if}
Otherwise, to show the "default category name" in the order confirmation email (for single product purchased) I'm in trouble ..
The /mails/it/order_conf.html file declares the {products} variable.
Where do I find the template to edit the {products} variable and then add the category name information?
Where is the reference file located?
Thanks
{products variable into order_conf.html}

Related

Prestashop add custom radio button on shipping carriers on front end checkout

I have created one custom module in Prestashop 1.7.8.7 which will add multiple shipping methods (Carrier) and will show shipping cost based on product dimensions and delivery address. So shipping carrier will look something like this on front-end checkout page. https://prnt.sc/E1avDASyJYYW
Now if someone select SameDay Courier Shipping then i need to show two radio button to select which service they want.
It will have two radio options like
Delivery pickup (by default this option will be selected)
Locker pickup
So if someone select Delivery pickup then it will have different shipping cost and if someone select Locker pickup then it will have different shipping cost.
Can anybody help me how can i achieve this functionality.
While digging, i found that we have file called DeliveryOptionsFinder.php and in that file we have one public function called getDeliveryOptions() where we have this line of code
if ($moduleId = Module::getModuleIdByName($carrier['external_module_name'])) {
$carrier['extraContent'] = Hook::exec('displayCarrierExtraContent', ['carrier' => $carrier], $moduleId);
}
}
So if i set is_module to 1 to all my carriers directly from DB then on frontend checkout page, no carriers is being displayed.
Thanks in advance.
I've already done something like this in the last 2 year as prestashop developer.
The truth is that you can't achieve what you want by "respecting" prestashop processes.
Maybe you can hook using a module the hookDisplayCarrierExtraContent($data) and then return the 2 radios if carrier is certain one (use $data).
But you can't handle a form submit or something else, or include it to prestashop checkout data.
But what you can do as workaround, for example, is the following.
In your module, as I said, hook the extra content, render a template with the 2 radios. Hook displayHeader too and use $this->context->controller->addJS() to add your own js if the current controller is the checkout one.
Then in this JS code you can handle the "change" event of the radios and send an ajax request to your module.
You can create inside {your_module}/controllers/front/ a controller called, for example, radio-choose and handle the js ajax request by saving inside your own table the choosen one.
Obviously you can disable the "next" button in checkout untill one of the two radios are selected, or maybe you can just set a radio button as default one to simplify.
For example your table "ps_cart_choosen_radio" could look like this |id_cart|choosen_radio|.
Then you have all the data you needed. When a cart is converted into an order you will have inside Order object (and ps_orders table as well) the id_cart.
Just select / join choosen radio from your own table by using order's id_cart.
"SELECT choosen_radio FROM ps_cart_choosen_radio WHERE id_cart = {$order.id_cart}"
If you need to show data depending on choosen_radio in frontend you can hook everywhere an order is present and select these data. Or maybe you can edit carrier name in ps_orders table by adding a piece of string. Let' say carrier is "express" and customer choosed "24h". You can update that column with carrier name by changing it to "express-24h" so around the whole prestashop ecosystem everybody will see that's a 24h choice.
Remember that the carrier name related to an order is not the carrier name inside the carriers table. So you can edit it without having trouble.
All these problems comes from the "need" to show some nested choices instead of listing all these in the main selections. In that case it would be easy (just create carrier in the prestashop backoffice)

Add custom text box with dynamic text on every product page

I want to add a couple of lines of dynamic text to my product description.
Like this text
What is the price of "product name" in Singapore?
The latest price of "product name" in Singapore is "product price" You can buy the "product name" at best price from our "store name" or visit "store address"
I don't want to visit every product page to add this.
And I want google to capture the question (attached picture)
https://ibb.co/3YJ8dmk
https://ibb.co/wS73jpr
How can I do it?
You should develop a simple module which uses one of the Prestashop product display hooks to show your dynamic informations.
A good starting point in module development is here
You can use one of theses hook to add your product custom fields (See the doc)
displayAdminProductsExtra
displayAdminProductsMainStepLeftColumnMiddle
displayAdminProductsMainStepLeftColumnBottom
displayAdminProductsMainStepRightColumnBottom
displayAdminProductsQuantitiesStepBottom
displayAdminProductsPriceStepBottom
displayAdminProductsOptionsStepTop
displayAdminProductsOptionsStepBottom
displayAdminProductsSeoStepBottom
See module demo to add custom fields https://github.com/PululuK/democustomfields17

Override email templates (mailalert module) in prestashop

We have an eshop in prestashop (1.6.1.12 version) with mail alerts module installed. The concept is to modify the email template in order to change the way some values are being displayed. In particular we would like to modify the new_order email notification (the one that the shop owner receive for every new order) removing the product links from the product list and display the shipping costs without tax (the total tax is visible on the next field of the email).
You have the template files in this directory:
/modules/mailalerts/mails/[your-language]

Showing different price on category page and single product page in variable product in bigcommerce

Showing different price on category page and single product page in variable product in bigcommerce. I just want to show the lowest price on category page.
This is the category page: https://hilineelectronics.com/portable-audio/. In the first product price is showing $112.99 and after checking it quick view and single product page it is showing $83.99. I want $83.99 (varibale amount) amount there.
How can we do this? Any variable or code for this?
Thanks in advance.
Go to your CategoryProductsItem.html check the code
<em class="p-price">%%GLOBAL_ProductPrice%%</em>
Is there %%GLOBAL_ProductPrice%% call same or different with product details page.
ProductDetails.html
<span class="ProductPrice VariationProductPrice">%%GLOBAL_ProductPrice%%</span>
Compare both files global varriable.
The second way makes the backup and of the files and then revert it to the original.

How to fix price error for a product in Magento?

I am trying to fix this product listing: http://shop.crystalvine.com/salt/blueberrysalt-c.html
You see in the dropdown there is an option for "refill" which is supposed to say $10.95 but says $45.95
When I log into Magento and click on Catalog --> Manage Products
There are f different listings for this product, differentiated by size/price. I try to edit the price by clicking "edit" on the product and under the price option on the left I edit the price and save.
But doing that to the products does not change the price on the live site when I edit the price for them.
Am I doing something wrong there? How do I change the price?
Thanks!!
This is a configurable product.
Make sure you change the price for the simple product having that option or in the configurable product page, choose "Associated products" and make the price change there.
Then you probably must reindex your catalog (System -> Index managment).