I am new to prestashop and using 1.6 version. I am creating a module which will show cart summary in pop up box after adding product into cart. The process of adding product into cart will be triggered, when customer clicks on "Add to cart" button.
So, i want to change the current functionality of "Add to cart button" and put my functionality on this.
I have searched many things on this, but everyone telling me that, this can be achieved by overriding tpl file. Its ok, but i have question on this that, if i override tpl file and after that user disable my module module then in that case, will overrided tpl file work??. Disable means just disable its functionality not uninstall the module.
So, please any one clear my confusion on this and tell me the right solution of how can i change the current functionality of "Add to cart" button and put my funcationality, when my module is enable??
Waiting for solution.
The best approach is to do an override, by copying the default template, and just remove/add code from it based on that if the module is enabled or disabled/uninstalled. These are just simple IFs, like:
{if Module::isInstalled('socialsharing')}
<div>SOCIAL</div>
{else}
<div>NO SICIAL</div>
{/if}
If course instead of isInstalled() method you can use isEnabledForShopContext() & isEnabled()
Related
I am using prestashop 1.7 and want to disable the popup and instead call a custom javascript function that toggles my shopping cart visible.
I found various instructions, however I don't have a file called ps_shoppingcart.js. The only one I have is the ps_shoppinccart.tpl which contains the HTML template.
Can someone help me to find where I can do the toggle?
If you take a look at the code of the master file of the module (ps_shoppingcart.php), you will see in the hookHeader() that the ps_shoppingcart.js is skipped when the option "Ajax cart" is turned off, so, you can remove these validation to keep the JS file loaded and in the file every time and now you can add your custom code, the code which show the popup is this:
if (resp.modal) {
showModal(resp.modal);
}
Hope this help you!
Recently I was doing some integrations on a non-standard/non-official prestashop 1.6 theme.
I found out after some manipulation on the Back-Office that the cart module doesn't appear on the Front-Office.
The cart module is enabled and is hooked to the displayNav and displayTop hooks.
It seems that cart module doesn't render any of its view code even when the "Disable module ovverides" is disabled.
The last and the only thing I've manipulated on the BO config is activating and then deactivating the "Force update friendly url".
Note that the current theme in based on an old theme and was made by an intern that didn't respect the official doc at all. What I mean by that is that you can find inline CSS and Javascript isnide a tpl file with no repsect of the smarty template engine syntax.
The current theme doesn't support many of the hooks that the default and basic prestashop theme offers.
I envisionned the following solution :
Read the 1.6 PS doc and make corrections on the theme. If the number of bugs, problems and mis-uses is not huge.
Rewrite the theme from groung zero in the worst case
After one day of lookin up answers on the web I found out that the catalog mode was off which makes the cart block disapears on the front-office.
I'm using Hotcakes Commerce DNN modules and I'd like to know how I can allow the user to stay on the product page after the "Add to Cart" button is clicked. The default behaviour is to redirect the user to the cart page whenever the a product is added to the cart.
The easiest way to make this happen is to modify your viewset to change how the add to cart buttons work. Here's a summary of the required steps:
Add and begin modifying your viewset if you haven't started already.
Modify your \VIEWSETNAME\Views\Products_ProductDetails.cshtml file to change the add to cart action from a post, to an AJAX link. This will allow you to add products to cart directly using a link, but keep you on the page.
If you're using the Mini Cart, refresh the page using JS so that it updates appropriately.
Please note that this option won't work well if your products have choices. If this is the case, you should instead allow your customers to be directed to the cart page, and use a parameter there to determine whether or not you redirect back to the product page.
I want to change the layout of prestashop back office product page.
So can anyone tell me which file to change so that I can modify this existing layout?
I don't know which page you want to edit exactly, but when you go to that page in your backoffice, like:
http://www.example.com/admin123/index.php?tab=AdminAttributesGroups
The admin123 is variable to your installation, but the ?tab=AdminAttributesGroups referes to the backoffice page you are on. These pages are located in /var/www/admin123/tabs in this case it's /var/www/admin123/tabs/AdminAttributesGroups.php
I found the solution.... Here is what I did
Added content.tpl in under adminxxyy/theme/theme_name/template/controller/products
Which showed me content of my content.tpl
Create a new module, register the hook and send that info via hook to content.tpl.
Use hook name in content.tpl like {hook h='displayProductMyWay' mod='blockcustom'}.
I would like to show a form in prestashop module and would like to store that value in database. How is it possible?? Is there any prestashop expert ??
You may use custom HTML block and add your form code inside that. And off course have to use a hook to show up that HTML block in the site.
There are lots of free Custom HTML block modules available.
You should take a look at all the modules available in the modules/ directory.
If you want to display a form in the back and/or the front office, you'll have to override different methods of the Module class, and you'll have to use the different hooks available..
Best regards,
Try this free module :
https://www.prestashop.com/forums/topic/391966-megablock-16-module-gratuit/
With this one you can add HTML in some hooks from back-office.
Everything is stored in database.
You should use Helpers and Tools class (Helpers show forms and Tools::getValues() does what it says...)
In MegaBlock there is also TinyMCE available. Have a look, this module is really useful ;-)
you can develop a module by using hooks based on the hooks used the form will be displayed in that position in prestashop while using hooks you need to assign a tpl file in that tpl file you can write the codings to display a form
And also you can develop a module with a separate controller and you can assign a tpl for that controller.