Jump to content

PhpMadman

Members
  • Posts

    277
  • Joined

  • Last visited

  • Days Won

    1

PhpMadman last won the day on August 27 2019

PhpMadman had the most liked content!

Profile Information

  • Location
    @PC
  • Activity
    Developer

Recent Profile Visitors

9,937,812 profile views

PhpMadman's Achievements

  1. If i remember correctly it is because your fields_list asks for quantity, and as you said, it matches both fields You can either change it to a.quantity or sa.quantity Or you can edit your select _select to 'sa.quantity AS qty' and change fields_list from quantity to qty. Assuming you want the quantity from stock_available
  2. Hello. I been away from PrestaShop coding for almost 2 years. So forgotten a lot. What is the best way to create a help page within the module? I added a lot of new feature, and next to module settings I want to show a help page explaining how the features work. I'm still using HelperForm for settings since it is 1.5 - 1.7 compatible. If it can't be done without building a controller page in admin, can I create a link to a notes.txt/html placed in the modules root then?
  3. Uhmm. Thank you. I guess? Any special reason for activating this 4 year old thread?
  4. Hi. The problem is that you don't set an array on name, description and link_rewrite. I have added an foreach loop on the products, so it adds the product and sets the same texts on all languages. I also think I have fixed the undefined indexes. You can find my changes by searching for //PhpMadman in the script. Hopefully it will get you what you want, or in the right direction. I'm note sure I have the time to help any more today. <?if(!defined("TDM_PROLOG_INCLUDED") || TDM_PROLOG_INCLUDED!==true)die(); //define('_PS_MODE_DEV_', true); $tm=time(); require($_SERVER["DOCUMENT_ROOT"].'/config/config.inc.php'); //$sql = 'SELECT * FROM `ps_1product` WHERE `id_product` = 10 '; //$arRes = Db::getInstance()->executeS($sql); //echo '<br><pre>';print_r($arRes);echo '</pre>'; global $TDMCore; if(!$context){$context = Context::getContext();} $PS_LANG = (string)$context->language->iso_code; //Groups: //$arPsUGroups = $context->customer->getGroups(); //array of linked groups $PsDefGroup = $context->customer->id_default_group; if(!TDM_ISADMIN){ $arPGID = $TDMCore->arPriceGID; foreach($arPGID as $TDM_GID=>$CMS_GID){ if($PsDefGroup==$CMS_GID){ if($_SESSION['TDM_USER_GROUP']!=$TDM_GID){$_SESSION['TDM_USER_GROUP']=$TDM_GID; Header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);} break; } } } //Lang // PhpMadman // Should fix undefined index error if(!isset($_GET['ulng']) || $_GET['ulng'] == '') { // if($_GET['ulng']==''){ if($PS_LANG AND TDM_LANG!=$PS_LANG AND in_array($PS_LANG,$TDMCore->arLangs)){ $_SESSION['TDM_LANG']=$PS_LANG; TDMRedirect($_SERVER['REQUEST_URI']); } } if(!TDM_ISADMIN){ $arPGID = $TDMCore->arPriceGID; global $USER; $arGroups = array((int)Group::getCurrent()->id); $isAuthorisedGroup = false; foreach($arPGID as $TDM_GID=>$CMS_GID){ if(in_array($CMS_GID,$arGroups)){ $isAuthorisedGroup = true; if($_SESSION['TDM_USER_GROUP']!=$TDM_GID){ $_SESSION['TDM_USER_GROUP']=$TDM_GID; header('Location: '.$_SERVER['REQUEST_URI']); } break; } } if (!$isAuthorisedGroup) { unset($_SESSION['TDM_USER_GROUP']); } } //Add to cart if(defined('TDM_ADD_TO_CART') AND TDM_ADD_TO_CART){ global $arCartPrice; if(is_array($arCartPrice)){ if($_REQUEST['QTY']>1){$QUANTITY=intval($_REQUEST['QTY']);}else{$QUANTITY=1;} // PhpMadman // Should fix undefined index if (isset($arCartPrice['OPTIONS']['MINIMUM'])) { if ($arCartPrice['OPTIONS']['MINIMUM'] > 1 AND $QUANTITY < $arCartPrice['OPTIONS']['MINIMUM']) { $QUANTITY=$arCartPrice['OPTIONS']['MINIMUM']; } } if($arCartPrice['OPTIONS']['MINIMUM']>1 AND $QUANTITY<$arCartPrice['OPTIONS']['MINIMUM']){$QUANTITY=$arCartPrice['OPTIONS']['MINIMUM'];} if($QUANTITY>$arCartPrice['AVAILABLE_NUM']){$QUANTITY=$arCartPrice['AVAILABLE_NUM'];} $DefaultCategory = intval($TDMCore->arSettings["CMS_DEFCATID"]); $Price = TDMConvertPrice($arCartPrice['CURRENCY'],$TDMCore->arSettings["CMS_ADDCART_CURRENCY"],$arCartPrice['PRICE']); $DefaultTaxGroup = 1; $VAT = 1.22; $PriceVAT = round($Price/$VAT,2); $Reference = $arCartPrice['ARTICLE'].' / '.$arCartPrice['BRAND']; //Presta init $logged = $context->cookie->__get('logged'); $id_cart = $context->cookie->__get('id_cart'); $id_lang = $context->cookie->__get('id_lang'); $id_guest = $context->cookie->__get('id_guest'); $id_currency = $context->cookie->__get('id_currency'); // Add cart if no cart found if (!$id_cart){ $context->cart = new Cart(); $context->cart->id_customer = $context->customer->id; $context->cart->id_currency = $id_currency; $context->cart->add(); if($context->cart->id){ $context->cookie->id_cart = (int)$context->cart->id; } $id_cart = (int)$context->cart->id; } $doAdd="Y"; //if(!$logged>0){$doAdd="N"; $TCore->arErrorMessages[] = 'You must be <a href="/index.php?controller=my-account">logged in</a> to buy products';} //if(trim($Reference)=='' OR !$Price>0 OR !$QUANTITY>0){$doAdd="N"; $TCore->arErrorMessages[] = 'Add to cart data is missing!';} if(!$id_cart>0){$doAdd="N"; ErAdd("Your cookie <b>id_cart</b> is wrong!",1);} if(!$id_lang>0){$doAdd="N"; ErAdd("Your cookie <b>id_lang</b> is wrong!",1);} if($doAdd!="N"){ //Check avail. tecdoc item in Presta $sql = 'SELECT p.`id_product`, pl.`name` FROM `'._DB_PREFIX_.'product` p LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product`) WHERE pl.`id_lang` = '.$id_lang.' AND p.`price` = '.$PriceVAT.' AND p.`reference` = "'.$Reference.'" '; $arRes = Db::getInstance()->executeS($sql); if(count($arRes)>0){ $NewTID = $arRes[0]['id_product']; }else{ //Supplier data (for 1C integration) $supplierName = $arCartPrice['SUPPLIER_STOCK']; /* $supplierId = SupplierCore::getIdByName($supplierName); if(!$supplierId){ $obSupp = new SupplierCore(null,$id_lang); $obSupp->name = $supplierName; $obSupp->active = 1; $obSupp->add(); $supplierId = $obSupp->id; }*/ //echo '<br><pre>';print_r($obSupp);echo '</pre>';die(); $obProduct = new Product(false,false,$id_lang); $obProduct->id_category_default = $DefaultCategory; $obProduct->id_category = $DefaultCategory; $obProduct->redirect_type = '404'; $obProduct->unity = $arCartPrice['ADD_URL']; // $obProduct->name = substr($arCartPrice['NAME'],0,128); // $obProduct->description = 'CARCONNECTION - ricambi auto per tutte le autovetture sul mercato a prezzi di concorrenza'; // $obProduct->description_short = $arCartPrice['SUPPLIER_STOCK'].' ['.$arCartPrice['DAY'].' days]'; $obProduct->price = $PriceVAT; $obProduct->show_price = 1; $obProduct->reference = $Reference; // $obProduct->link_rewrite = $arCartPrice['CPID']; $obProduct->available_for_order = 1; //true $obProduct->visibility = 'none'; //both $obProduct->is_virtual = 0; $obProduct->id_tax_rules_group = 8; //PhpMadman // Sets same texts for all languages $languages = Language::getLanguages(); foreach($languages as $lang) { $obProduct->name[$lang] = substr($arCartPrice['NAME'],0,128); $obProduct->description[$lang] = 'CARCONNECTION - ricambi auto per tutte le autovetture sul mercato a prezzi di concorrenza'; $obProduct->link_rewrite[$lang] = $arCartPrice['CPID']; $obProduct->description_short[$lang] = $arCartPrice['SUPPLIER_STOCK'].' ['.$arCartPrice['DAY'].' days]'; } if(isset($arCartPrice['OPTIONS']['WEIGHT']) AND $arCartPrice['OPTIONS']['WEIGHT']>0){$obProduct->weight = round($arCartPrice['OPTIONS']['WEIGHT']/1000,2);} if(isset($arCartPrice['OPTIONS']['MINIMUM']) AND $arCartPrice['OPTIONS']['MINIMUM']>0){$obProduct->minimal_quantity = $arCartPrice['OPTIONS']['MINIMUM']; $QUANTITY=$arCartPrice['OPTIONS']['MINIMUM'];} if(isset($arCartPrice['OPTIONS']['USED']) AND $arCartPrice['OPTIONS']['USED']>0){$obProduct->condition = 'used';} if(isset($arCartPrice['OPTIONS']['RESTORED']) AND $arCartPrice['OPTIONS']['RESTORED']>0){$obProduct->condition = 'refurbished';} //supplier //$obProduct->supplier_name = $supplierName; //$obProduct->id_supplier = $supplierId; //echo '<br><pre>';print_r($obProduct);echo '</pre>'; $obProduct->add(); if($obProduct->id>0){ $NewTID = $obProduct->id; $obProduct->addToCategories(array($DefaultCategory)); //$obProduct->setWsCategories(Array("id"=>$DefaultCategory)); //Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'category_product` (`id_category`, `id_product`, `position`) VALUES ('.$DefaultCategory.','.$NewTID.',0)'); //Add image if($arCartPrice['IMG_SRC']!='' AND $NewTID>0){ $shops = Shop::getShops(true, null, true); $image = new Image(); $image->id_product = $NewTID; $image->position = Image::getHighestPosition($NewTID)+1; $image->cover = true; // or false; if(($image->validateFields(false, true)) === true && ($image->validateFieldsLang(false, true)) === true && $image->add()){ $image->associateTo($shops); $tmpfile = tempnam(_PS_TMP_IMG_DIR_, 'ps_import'); if(Tools::copy($arCartPrice['IMG_SRC'], $tmpfile)){ $path = $image->getPathForCreation(); ImageManager::resize($tmpfile, $path.'.jpg'); } unlink($tmpfile); } } }else{ ErAdd("Prestashop new Item ID is false",1); } unset($obProduct); } if($NewTID>0){ if($arCartPrice['AVAILABLE_NUM']>0){StockAvailable::setQuantity($NewTID, false, $arCartPrice['AVAILABLE_NUM']);} $obCart = new Cart($id_cart); $obCart->id_lang = $id_lang; $obCart->id_currency = $id_currency; if($obCart->updateQty($QUANTITY,$NewTID)){ Header('Location: http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); die(); }else{ ErAdd("Prestashop Add to Cart is false. NewTID=".$NewTID.', CartID="'.$id_cart.'"', 1); } } } } } ?> <script src="/<?=TDM_ROOT_DIR?>/media/js/jquery214.min.js"></script> <?php $_GET=Array(); $controller = new FrontController(); $tm=time(); $controller->init(); //echo 'init() '.(time()-$tm).' sec.<br>'; $tm=time(); //$controller->initContent(); //echo 'initContent() '.(time()-$tm).' sec.<br>'; $tm=time(); $controller->setMedia(); //$controller->initHeader(); $context->smarty->tpl_vars['page']->value['page_name'] = 'TDMod'; $context->smarty->tpl_vars['page']->value['meta']['title'] = TDM_TITLE; $context->smarty->tpl_vars['page']->value['meta']['description'] = TDM_DESCRIPTION; $context->smarty->tpl_vars['page']->value['meta']['keywords'] = TDM_KEYWORDS; $context->smarty->tpl_vars['page']->value['meta']['robots'] = ''; $controller->displayHeader(); //echo 'displayHeader() '.(time()-$tm).' sec.<br>'; $tm=time(); ?> <script src="/<?=TDM_ROOT_DIR?>/media/js/jquery214.min.js"></script> <script src="/<?=TDM_ROOT_DIR?>/media/js/colorbox/jquery.colorbox-min.js"></script> <link rel="stylesheet" href="/<?=TDM_ROOT_DIR?>/media/js/colorbox/cmain.css" /> <table><tr><td><?$arMSParams["LANG"]='it'; require_once($_SERVER["DOCUMENT_ROOT"].'/autoparts/addons/vin/component.php');?> </td><td> <?$arKTParams["LANG"]='it'; require_once($_SERVER["DOCUMENT_ROOT"].'/autoparts/addons/mselect/component.php');?> </table> <? require_once($_SERVER["DOCUMENT_ROOT"].'/autoparts/addons/vin/component.php'); ErShow(); echo $TDMContent; $controller->displayFooter(); /* $_GET=Array(); //require($_SERVER["DOCUMENT_ROOT"]."/header.php"); ob_start(); require($_SERVER["DOCUMENT_ROOT"]."/header.php"); ?> <script src="/<?=TDM_ROOT_DIR?>/media/js/jquery214.min.js"></script> <?php $PrestaHeader = ob_get_contents(); $PrestaHeader = str_replace(array('</body>','</html>'),'',$PrestaHeader); $PrestaHeader = str_replace('id="pagenotfound"','',$PrestaHeader); $PrestaHeader = str_replace('class="pagenotfound"','',$PrestaHeader); ob_end_clean(); echo $PrestaHeader; ?> <script src="/<?=TDM_ROOT_DIR?>/media/js/jquery214.min.js"></script> <script src="/<?=TDM_ROOT_DIR?>/media/js/colorbox/jquery.colorbox-min.js"></script> <link rel="stylesheet" href="/<?=TDM_ROOT_DIR?>/media/js/colorbox/cmain.css" /> <table><tr><td><?$arMSParams["LANG"]='it'; require_once($_SERVER["DOCUMENT_ROOT"].'/autoparts/addons/vin/component.php');?> </td><td> <?$arKTParams["LANG"]='it'; require_once($_SERVER["DOCUMENT_ROOT"].'/autoparts/addons/mselect/component.php');?> </table> <? require_once($_SERVER["DOCUMENT_ROOT"].'/autoparts/addons/vin/component.php'); ErShow(); echo $TDMContent; require($_SERVER["DOCUMENT_ROOT"]."/footer.php"); */ ?>
  5. When I do something similar, I go in to the Database manually, and change the created_at date.
  6. Hi. I'm creating a special site for some of our customers. Registered customers only. I create accounts for them, and then they add product to cart. And then in Checkout I want to force that the billing address is the one I added when I registered the account. Should be something simple as just getting the lowest id for that customer I guess. But the delivery address, should and must always be submitted as a new address. I started by hiding Delivery / Billing address boxes. Then there is only the add address button, but that redirects to a new page. I want the customers to be able to add the address directly in the OPC, just as new / guest customers do. And then that address should be auto selected as delivery address. Any ideas how to accomplish this in the simplest way? Module, override, theme changes?
  7. Hej. Har fortfarande inte börjat på API supporten, och det kommer nog dröja ett tag till. Har väldigt mycket att göra på jobbet nu. Men under tiden så har jag lagt upp modulen som vanlig enkel betalningmodul. Fungerar precis som BankWire, visar betalningsinfo efter att man bekräftat ordern. https://www.prestashop.com/forums/topic/522905-madswish-for-swedish-swish-payments/
  8. Hej. Har blivit lite försenad med att bli färdig med en enkel Swish modul. En som bara visar Swich info så som Bankwire gör. Jag vill helst göra en mer avancerad, Jag har bara hört talas om att Swish ska ha ett api, så att man kan automatisera det, är det någon som har en länk till det eller mer info?
  9. Hej. Verkar som många är intresserad av en enkel Swish modul. Jag håller på att göra en, tänkte kolla vad ni vill att den innehåller. Jag har tänkt att fixa så att man kan välja vilken status en Swish order ska få. Och så anger man bara Nummer och Mottagare. Samt att när man installerar den så ska ett mail template installeras. Så att det finns möjlighet att skicka ut ett mail precis som med Bankwire. Modulen bygger på Bankwire. Dock kommer denna inte kräva att man ersätter Bankwire utan det kommer vara en helt egen modul.
  10. Hmm. Seems I never uploaded the file to enable dev mode. It's the little things. It was missing link_rewrite. Added that, name and description and my test code worked just fine. And also, this error did not produce any error / server log *EDIT* Real code works fine, all text / price file gets updated. Now I'll just need to figure out how to download and add the product images... Thanks for you help.
  11. Beacuse i'm updateing a product. But neither update, add or save works, all of them gives me a 500 Error,
  12. And what background are you talking about? The one in body, that seems to do nothing: url("/modules/belvg_backgroundpages/patterns/blank") The one in body, header, .columns-container: url("http://www.supplements-anabolic.com/metal4test2") The on in header, .columns-container, .header-container: url("http://www.supplements-anabolic.com/back1") And what do you want it to do exactly?
  13. Yes. In global, at #page line 5303 You can play around here, to see what code you want. http://css3gen.com/box-shadow/
  14. Hi. I can't see the css, beacuse for some reason, my browser get's stuck on your connect.facebook.net call. But to shadow something -webkit-box-shadow: 7px 7px 10px 0px rgba(50, 50, 50, 1); -moz-box-shadow: 7px 7px 10px 0px rgba(50, 50, 50, 1); box-shadow: 7px 7px 10px 0px rgba(50, 50, 50, 1);
  15. Another update. Even this small code causes 500 Error, and second ECHO is not displayed in browser, but still updates the reference. echo('Test Code<br>'); $resource = new Product(1599); $resource->reference = 'TEST '.date('Y-m-d H:i:s'); $resource->update(); $resource = null; echo('Test Code End<br>');
×
×
  • Create New...