Jump to content


  • Posts

  • Joined

  • Last visited

Axari's Achievements


Newbie (1/14)



  1. Hi everyone, Prestashop here I have a custom module that allows a user to paste a list of items into a window, and the shop does a lookup and gives them proper add-to-cart buttons. I'd like to add a button that add's their entire list to the cart without them having to click individually though. (like a single-click button that adds multiple items to the shopping cart) I have tried: http://shopdomain.com/cart.php?add&id_product=11134&id_product=11132&id_product=11129&token= but it only adds the last item in the string. and... http://shopdomain.com/cart.php?add&id_product=11134,11132,11129&token= but it only adds the first item in the string. Does anyone know how to do this? Any advise would be appreciated!
  2. Hi guys, How can I disable jqZoom and Thickbox? I don't want anyone to be able to click on the large product image for the Thickbox, or mouseover to get the jqzoom effect. In product.tpl, under the image-block section (where the large picture shows up) I changed the {if $have_image} section and removed all references to thickbox/jqZoom. <img src="{$link->getImageLink($product->link_rewrite, $cover.id_image, 'large')}" title="{$product->name|escape:'htmlall':'UTF-8'}" alt="{$product->name|escape:'htmlall':'UTF-8'}" id="bigpic" width="{$largeSize.width}" height="{$largeSize.height}" /> But I still have the thickbox affect. Any guidance would be great!
  3. doekia, Thanks for the Skype conversation, the education on Prestashop's functions, and for cleaning up my mess! To everyone else - If your looking for a developer that's friendly and knowledgeable, checkout doekia's services.
  4. Hi Everyone, I've got a controller and template nearly done (special thanks to razaro!) but I'm having trouble with the last piece of it. My controller and template are below. My goal is for the user to submit a wishlist, and the controller looks up the items and matches it to the database, which the template displays the results of. (Preferably how product-list.tpl displays products, but I'm not really that picky at the moment) The form works. The controller gets the list. It's cleaned up, and it hits the foreach statement. At that point, the template only shows the last item in the wishlist. That's where I need some help Yes, I'm sure there's a cleaner way to get this done. But I need it working right now. Any help would be appreciated! Controller - <?php // // Eft Import Controller // v12.13.2011 // class EftImportControllerCore extends FrontController { public $php_self = 'eftimport.php'; public function preProcess() { parent::preProcess(); // If the submit button was clicked if (Tools::isSubmit('submit_eft')) { $eftdata = Tools::htmlentitiesUTF8(Tools::getValue('eftdata')); // Cleanup the array and get it ready for the DB queries // Connect to Database // Cycle through the array and lookup each item foreach ($eft_data as $item) { // Query 1 - get product id & name $query = "SELECT l.id_product, l.name FROM ps_product_lang l WHERE name = '$item'"; $id_result = mysql_query($query) or die(mysql_errno().": ".mysql_error()."<BR>"); $id = @mysql_result ($id_result, $i, "id_product"); // Product ID $name = @mysql_result ($id_result, $i, "l.name"); // Product Name // Query 2 - Grab the item price & Image ID (graphics in the shop are "id_product.id_image.jpg" format) $query = "SELECT ps_product.price, ps_image.id_image FROM ps_product INNER JOIN ps_image ON ps_product.id_product=ps_image.id_image WHERE ps_product.id_product = '$id'"; $result = mysql_query($query) or die(mysql_errno().": ".mysql_error()."<BR>"); $price = @mysql_result ($result, $i, "p.price"); // Dirty Product Price $price = number_format($price, 2, '.', ','); // Clean Product Price $id_img = @mysql_result ($result, $i, "i.id_image");// Image ID // Smarty stuff $results = array('id'=>$id, 'name'=>$name, 'price'=>$price, 'id_img'=>$id_img, 'addtocart'=>$addtocart); self::$smarty->assign('results', $results); } } else{ self::$smarty->assign('eftdata', ''); } } public function displayContent() { parent::displayContent(); self::$smarty->display(_PS_THEME_DIR_.'eftimport.tpl'); } } ?> Template - {* * EFT Import Template * v12.13.2011 *} {capture name=path}{l s='EFT Import'}{/capture} {include file="$tpl_dir./breadcrumb.tpl"} <div class="pl_category"> <h1>{l s='EFT Import'}</h1> <div class="pl_ct"> <br /> {if isset($results)} <h4>{l s='EFT Import Results'}</h4> <br> <div > {foreach from=$results key=k item=result} <span id={$k} >{$result}</span> {/foreach} </div> {else} ** Display Form ** {/if} </div> </div>
  5. I've turned on: in config/config.inc.php to @ini_set('display_errors', 'on'); and in tools\smarty\Smarty.class.php to // debug mode public $debugging = true; But I can't see what's being posted. Anyone know how I can see if it's getting the data I'm posting? Do I need to add something to the first php file to pass the form data to the controller? require(dirname(__FILE__).'/config/config.inc.php'); ControllerFactory::getController('TestController')->run();
  6. I think my issue might be that the function isn't getting the $data from the post. Anyone know how to get the data, and verify it received it? Many thanks!
  7. You are awesome Razaro! Many thanks, that helped a lot. I have one (I hope...) last hangup. When I submit the form, the form just re-displays. So I'm missing something somewhere. Can you glance at this and possibly give me a suggestion? (Yes, I'm sure there are more efficient ways to code this. Right now I'm just trying to get it to work again. And I probably need to update the database requests for PS 1.4 so ignore the details..) (I don't get any Smarty errors) Controller - <?php class EImportControllerCore extends FrontController { public $php_self = 'e_import.php'; public function EImport() { // Get posted vars $data = $_POST["data"]; // If the submit button was clicked if ($data) { // Function: Replace breaks/returns with commas function mynl2br($text) { return strtr($text, array("\r\n" => ',', "\r" => ',')); } // Run the function & re-create the string $data = mynl2br($data); // Cleanup Array foreach ($data as &$item) { // Trim whitespace $item = trim($item); // Slashes $item = addslashes($item); } // Remove blank array elements to clean it up function array_remove_empty($arr){ $narr = array(); while(list($key, $val) = each($arr)){ if (is_array($val)){ $val = array_remove_empty($val); // does the result array contain anything? if (count($val)!=0){ // yes :-) $narr[$key] = $val; } } else { if (trim($val) != ""){ $narr[$key] = $val; } } } unset($arr); return $narr; } $data = array_remove_empty($data); // Now we need to lookup each item in the array to get the Product ID // // Connect to Database $connection = mysql_connect("***", "***", "***") or die("Could not connect"); if ($connection == false) { echo mysql_errno().": ".mysql_error()."<BR>"; exit; } // Select the database mysql_select_db("***") or die("Could not select the shop database"); foreach ($data as $item) { // Query 1 - get product id & name $query = "SELECT l.id_product, l.name FROM ps_product_lang l WHERE name = '$item'"; $id_result = mysql_query($query) or die(mysql_errno().": ".mysql_error()."<BR>"); $id = @mysql_result ($id_result, $i, "id_product"); $name = @mysql_result ($id_result, $i, "l.name"); // Query 2 - Grab the item price $query = "SELECT p.price FROM ps_product p WHERE p.id_product = '$id' "; $p_result = mysql_query($query) or die(mysql_errno().": ".mysql_error()."<BR>"); $price = @mysql_result ($p_result, $i, "p.price"); $price = number_format($price, 2, '.', ','); // Query 3 - Grab the image id (graphics in the shop are "id_product.id_image.jpg" format) $query = "SELECT i.id_image FROM ps_image i WHERE i.id_product = '$id' "; $i_result = mysql_query($query) or die(mysql_errno().": ".mysql_error()."<BR>"); $id_img = @mysql_result ($i_result, $i, "i.id_image"); // We don't want to display the add to cart button if the price is $0.00 if ($price == 0.00){ $name = "<font color='red'>$item</font>"; $price = "<font color='red'><center>-</center></font>"; $addtocart = "<font color='red'><center>Not Available</center></font>"; } if ($price != 0.00){ $price = $price'; $addtocart = "<a class='button ajax_add_to_cart_button exclusive' rel='ajax_id_product_$id' href='cart.php?add&id_product=$id'>Add to cart</a>"; } // Smarty stuff $results = array('id'=>$id, 'name'=>$name, 'price'=>$price, 'id_img'=>$id_img, 'addtocart'=>$addtocart); $smarty->assign('results', $results); } } } public function displayContent() { parent::displayContent(); self::$smarty->display(_PS_THEME_DIR_.'e_import.tpl'); } } ?> Template - {* * E Import Template *} {capture name=path}{l s='E Import'}{/capture} {include file="$tpl_dir./breadcrumb.tpl"} <div class="pl_category"> <h1>{l s='E Import'}</h1> <div class="pl_ct"> {if isset($results)} <h4>{l s='E Import Results'}</h4> <br> <div > {foreach from=$results key=k item=result} <span id={$k} >{$results}</span> {/foreach} </div> {/if} <br /> <h4>{l s='Welcome to E Import'}</h4> <form id='e_import' name='e_import' method='post' action='e_import.php'> <br /> Paste your wishlist in the box below<br /><br /> <textarea name='data' id='data' cols='65' rows='30'></textarea> <br /> <br /> <input name='submit' type='submit' value='Submit'> </form> </div> </div>
  8. Thanks Razaro, that got me headed in the right direction I'm kind of stuck at the moment though. I have tried creating an array with my data; $result = array(id=>'$id', name=>'$name', price=>'$price', id_img=>'$id_img', addtocart=>'$addtocart'); But your example above with the foreach statement doesn't work. So I tried: $smarty->assign('id', '$id'); $smarty->assign('name', '$name'); $smarty->assign('price', '$price'); $smarty->assign('id_img', '$id_img'); $smarty->assign('addtocart', '$addtocart'); Thinking that I could at least display it on the tpl. By using (for example): {$id} in the tpl, but it doesn't display anything. Is there a way to tell smarty to display everything that's sent to it? (like a debug mode) Where am I going wrong? (I checked the smarty docs on their website too, but I'm just not getting this)
  9. Okay, need some guidance I have a test.php file - require(dirname(__FILE__).'/config/config.inc.php'); ControllerFactory::getController('TestController')->run(); Then I have a controller for it - class TestControllerCore extends FrontController { public $php_self = 'test.php'; public function TestStuff() { // Get vars $data = $_POST["data"]; $option = $_POST["option"]; // If the submit button was clicked if ($data) { // Run script, connect the database & echo results } // If no criteria else { echo" <form id='import' name='import' method='post' action='test.php'> Import <br/> Paste your wishlist in the box below<br /><br /> <textarea name='data' id='data' cols='65' rows='30'></textarea> <br /> <br /> <input name='submit' type='submit' value='Submit'> </form>"; } return $TestStuff; } public function displayContent() { parent::displayContent(); self::$smarty->display(_PS_THEME_DIR_.'test.tpl'); } } Then I have a TPL file - {$TestStuff} Display something nice. I get a center page (with the shop template around it) and it says "Display something nice." How do I make it display the output of my custom function (TestStuff) though? I probably need to make a change in the controller and the tpl - but I'm not sure what exactly. Any help would be appreciated! P.S. I should also mention, that the first page displayed is a form which posts to itself. So If I need to know anything to make that work, that would also be helpful! [Edit] Added basic example in Controller
  10. Thanks Ruud! So what I've learned so far is... A. I spent hours searching, and came up with nothing that was helpful. So I apparently fail at searching. B. If I want to use a module to do what I want, I need to use a CMS page. Not exactly what I'd like C. Going about this the way I was (module & PHP in TPL files) is not the best approach. I probably need to do my own controller, and have it return my php output as a smarty variable that gets displayed in my .tpl file. I'm going to see if I can work on that... But haven't found any good docs on creating them. So I'll see what I can break. As far as what I'm doing? I need an input box (like a comment box) which will allow people to paste items into it. 1 item per row. Think of that as someone's wishlist they made. Then for every item that's available they'll get an add to cart button. (There's more to it than that, but that's the high level) Thanks for taking the time to get me on the right path MeRuud!
  11. If your asking about how to include your product photos with a Product import, then i might be able to help. Here's what I do - Make a directory in /img called import (as an example). Upload all the images you need to import into /img/import In the product.csv add a column called Image URL For each product, add the directory and filename of the picture. * It's helpful to know that the path to the file in your CSV is the relative path. Based on the example above, we would use: ../img/import/product.jpg Obviously change /import to whatever you called your folder in the /img directory. And change product.jpg to fit your needs (the product image filename and extension) Good luck
  12. ..... and this is why I keep thinking about switching eCommerce platforms. Never any help when you need it. (Yes, I'm a little frustrated at this point)
  13. No one can help, or point me in the right direction? (Tutorials, wiki, a post with a good walk through, anything...)
  14. I've read Rocky's guide on making a new module, which was very helpful. However, I have a few questions I'm hoping all of you can help me with; 1. How do I make a module display it's own (center/content) page? I see in rocky's hook list there isn't a center/content hook, only the home page hook. Which isn't what I need... Does this mean modules are limited to leftColumn, rightColumn, etc standard placements? 2. I got the module to install and display text. But the php just kind of spews all over... How do I properly add PHP into the TPL files so the script runs as intended without smarty getting in the way? (I tried {literal} tags, without any success) 3. I thought I'd try making my script a module that can run, but obviously running into challenges. If modules are limited (or not intended to be used the way I'm attempting to use them) then what is the best method for implementing my own center/content page, with my own script(s) running on it? (PHP specifically) Appreciate everyone's time!
  • Create New...