sanjar12345 Posted August 9, 2014 Share Posted August 9, 2014 Hello, I saw this plugin for Prestashop http://www.prestashop.com/forums/topic/309565-module-cryptocurrency-accept-payments-in-bitcoins-litecoins-dogecoins-etc/ I saw that it already had an auto updated (currency exchange) for BTC and DOGE so I decided to see if I could update it to also allow "Stellar" to be auto updated. I looked over this code twice and don't think there is anything wrong with it yet I get the following errors in prestashop. 2 errors cryptocurrency (parse error in /modules/cryptocurrency/cryptocurrency.php) cryptocurrency (class missing in /modules/cryptocurrency/cryptocurrency.php) Here is my cryptocurrency.php http://pastebin.com/7Q1jiVea Thank you for all your help Link to comment Share on other sites More sharing options...
vekia Posted August 10, 2014 Share Posted August 10, 2014 that's all what you see? nothing more? there is no info about error codes related to line in file ? Link to comment Share on other sites More sharing options...
vekia Posted August 10, 2014 Share Posted August 10, 2014 //update btc conversion rate if the user loads a page and has btc as current currency public function hookHeader($params){ if(Configuration::get('CRYPTO_CURRENCY_UPDATE_STELLAR')){ $stellar_code = 'STELLAR'; $cart_currency = $this->context->cart->id_currency; $stellar_currency_id = Db::getInstance()->executeS(' SELECT `id_currency` FROM `'._DB_PREFIX_.'currency` WHERE `iso_code`=\''.$stellar_code.'\''); if($stellar_currency_id && $stellar_currency_id[0]['id_currency']==$cart_currency){ //some code snippets taken from bitcointicker module $default_currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); $response = file_get_contents('http://coinmarketcap-nexuist.rhcloud.com/api/str'); $object = json_decode($response); if(is_object($object)){ $curr = strtolower($default_currency->iso_code);//'USD'; //$rate = $object->$curr->{'last'}; $rate = $object->{'price'}->$curr; $rate_default = 1.0/floatval($rate); $rate_default_str = trim(sprintf("%.6f", $rate_default)); //update conversion_rate on currency table $query='UPDATE IGNORE `'._DB_PREFIX_.'currency` SET `conversion_rate` = \''.$rate_default_str.'\' WHERE `iso_code` = \''.$stellar_code.'\''; //print_r($query); $return = Db::getInstance()->Execute($query); //update conversion_rate in currency_shop table too $curr_id = strval($stellar_currency_id[0]['id_currency']); $query2='UPDATE IGNORE `'._DB_PREFIX_.'currency_shop` SET `conversion_rate` = \''.$rate_default_str.'\' WHERE `id_currency`=\''.$curr_id.'\''; $return = Db::getInstance()->Execute($query2); } } } this code is out of class brackets Link to comment Share on other sites More sharing options...
sanjar12345 Posted August 10, 2014 Author Share Posted August 10, 2014 that's all what you see? nothing more? there is no info about error codes related to line in file ? Nope, that's all. I uploaded the files to the module section and that's what I see at the top of my module in the backend of PS 1.6 Link to comment Share on other sites More sharing options...
sanjar12345 Posted August 10, 2014 Author Share Posted August 10, 2014 //update btc conversion rate if the user loads a page and has btc as current currency public function hookHeader($params){ if(Configuration::get('CRYPTO_CURRENCY_UPDATE_STELLAR')){ $stellar_code = 'STELLAR'; $cart_currency = $this->context->cart->id_currency; $stellar_currency_id = Db::getInstance()->executeS(' SELECT `id_currency` FROM `'._DB_PREFIX_.'currency` WHERE `iso_code`=\''.$stellar_code.'\''); if($stellar_currency_id && $stellar_currency_id[0]['id_currency']==$cart_currency){ //some code snippets taken from bitcointicker module $default_currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); $response = file_get_contents('http://coinmarketcap-nexuist.rhcloud.com/api/str'); $object = json_decode($response); if(is_object($object)){ $curr = strtolower($default_currency->iso_code);//'USD'; //$rate = $object->$curr->{'last'}; $rate = $object->{'price'}->$curr; $rate_default = 1.0/floatval($rate); $rate_default_str = trim(sprintf("%.6f", $rate_default)); //update conversion_rate on currency table $query='UPDATE IGNORE `'._DB_PREFIX_.'currency` SET `conversion_rate` = \''.$rate_default_str.'\' WHERE `iso_code` = \''.$stellar_code.'\''; //print_r($query); $return = Db::getInstance()->Execute($query); //update conversion_rate in currency_shop table too $curr_id = strval($stellar_currency_id[0]['id_currency']); $query2='UPDATE IGNORE `'._DB_PREFIX_.'currency_shop` SET `conversion_rate` = \''.$rate_default_str.'\' WHERE `id_currency`=\''.$curr_id.'\''; $return = Db::getInstance()->Execute($query2); } } } this code is out of class brackets Sorry, what do you mean with "class brackets" Link to comment Share on other sites More sharing options...
vekia Posted August 10, 2014 Share Posted August 10, 2014 structure of well coded module looks like: class ModuleName extends Module { // code of module public function doSomething(){ } } your code looks like: class ModuleName extends Module { // code of module } public function doSomething(){ } as you can see public function doSomething() is outside class ModuleName extends Module { } all module functions must be inside class, not outside Link to comment Share on other sites More sharing options...
sanjar12345 Posted August 11, 2014 Author Share Posted August 11, 2014 Ah okay. Thanks for the reply, was this a fault with the original plugin linked or my adaptation of it? I haven't checked the plugins without any adaptations Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now