Jump to content

alejandro

Members
  • Posts

    91
  • Joined

  • Last visited

Everything posted by alejandro

  1. Hello, I think I installed the ProccessLanguage module before installing LanguageSupport. Now while trying to install it, an error is shown: TemplateFile: Unable to install module 'LanguageSupport': SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'languages-22' for key 'name_parent_id'<pre>#0 [internal function]: Modules->___install('LanguageSupport') #1 ...... (continues) I've uninstalled Processlanguage but throws the same error anyway, and it seems to install it again: LanguageSupportInstall: Installed ProcessLanguage although I've even deleted it from /wire/modules/LanguageSupport. ¿? The PW version running is 2.4.10, tried again downgrading to 2.4 and behaves identically. Thanks in advance, Alejandro.
  2. Uaaah! Can´t try it right now, but I understand it and it seems quite clear. I was having headaches thinking about possible weird solutions, like using two different passwords for each user (probabily not doable). Maybe later, when coding it, I'll have some doubts but I see the way to do it. Thank you very much.
  3. https://wiki.foxycart.com/v/1.1/customers#synchronizing_users_and_passwords It shows a list with the available methods to use with Foxycart. There are several options, for different CMSs, eg Wordpress or Drupal, salt included. I need Processwire to use one of this methods in order to sync the password between the PW users and Foxy users, as I understand I need to use the same hash method + salt so a user registered through Foxy could not login / validate password in PW, because the hashes would be different.
  4. Indeed, he helped me with the script that process the Foxycart datafeed. Thanks anyway
  5. Hello, I'm learning about password management/security in order to synchronize logins between PW users and Foxycart. In Foxycart I need to choose the password hash type I'm using. In my installation of PW wire->config.php shows: $config->userAuthHashType = 'sha1'; But in the post https://processwire.com/talk/topic/2954-password-hashing/ Ryan says: I'm using 2.4.4 version. As the server which PW shows blowfish is available I understand PW is using it. Foxycart doesn´t list this hash algorithm available. So, where should I change the hash method in wire->config? but it is overriden if blowfish is available in the server anyway? I'm a bit lost here , any direction / help would be appreciated.
  6. Hello, I fail to make it work. I'm using PW version 2.4.4. TemplateFile.php lines 156-158 are correctly updated: public function getArray() { return array_merge($this->fuel->getArray(), parent::getArray()); } My Hanna code is as simple as: [[page-title]] : <?php echo $page->title; The structure is as follows: Page texts, with title "Texts" -> Field "Text 1" (Textareas ProField)-> "Some text... " . [[page-title]] Page product name, with title "Product name"-> API reference to Field "Text 1" Outputs "Some text... Texts" Should be "Some text... Product name" I think it should work, but can´t see the problem. The textareas field has Hanna Code Text Formatter applied. Thanks,
  7. Mmm, but I don´t see how, as the selecting field belongs to the parent´s children, not to the parent itself; and there is no method: "child.name= " or something similar.
  8. Well, I found a way. Instead os selecting parents by children fields values, first find the pages, then select the parent: $children = $pages->find("name=value"); foreach ($children as $child) { $parent = $child->parent; }
  9. Hello, I don´t know if it is posible to find pages that have a children with name, I mean, something like: $parent = $pages->find("template=opciones, child.name=tarjetas") This of course doesn´t work, but something similar? Thanks in advance, Alejandro.
  10. Finally! It works! Well it was about slashes... when including the scripts $rc4cryptPaht = "/inc/clas...." doesn´t work $rc4cryptPaht = "inc/clas...." it works. Same for the parser. Addtionally in the Foxycart settings, the datafeed URL needs a slash at the end, otherwise returns an error: http://site.com/feed/ Now, it returns 'foxy' and creates the page in PW. ehem, as a designer, these "subtleties" don´t seem always that important. Your script is working great, thank you. Maybe you could post this Foxycart integration to their docs: https://wiki.foxycart.com/integration/start
  11. Doesn´t work for me Meanwhile i found a different solution, it needs a bit of javascript: 1) In my endpoint set up a script that'd request the transaction info using curl. It needs the transacton id to do so: <?php $foxy_domain = "domain.foxycart.com"; $foxyData = array(); $foxyData["api_token"] = "apikey"; $foxyData["api_action"] = "transaction_get"; $foxyData["transaction_id"] = $_GET["fcorderid"]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://" . $foxy_domain . "/api"); curl_setopt($ch, CURLOPT_POSTFIELDS, $foxyData); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_TIMEOUT, 15); // If you get SSL errors, you can uncomment the following, or ask your host to add the appropriate CA bundle // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $response = trim(curl_exec($ch)); // The following if block will print any CURL errors you might have // if ($response == false) { // print "CURL Error: \n" . curl_error($ch); // } else { // print "Response to customer save of " . $foxyData['customer_email'] . "\n"; // print $response; // } curl_close($ch); $foxyResponse = simplexml_load_string($response, NULL, LIBXML_NOCDATA); $client = $foxyResponse->transaction->customer_first_name; $transaction_id = $foxyResponse->transaction->id; $email = $foxyResponse->transaction->customer_email; $product = $foxyResponse->transaction->transaction_details->transaction_detail->product_name; $price = $foxyResponse->transaction->transaction_details->transaction_detail->product_price; foreach ($foxyResponse->transaction->transaction_details->transaction_detail->transaction_detail_options->transaction_detail_option as $option) { $product_option_name = $transaction_detail_option->product_option_name; $product_option_value = (string)$transaction_detail_option->product_option_value; $price_mod = (double)$transaction_detail_option->price_mod; } print "<pre>"; print_r($foxyResponse); print "</pre>"; $fwd = $pages->get("title=$transaction_id"); if($fwd->id) { $session->redirect($fwd->url); } else { $p = new Page(); $p->parent = $pages->get("1350"); $p->template = $templates->get("upload_area"); $p->title = $transaction_id; $p->email = $foxyResponse->transaction->customer_email; $p->fcdate = $foxyResponse->transaction->transaction_date; $p->fcfirst = $foxyResponse->transaction->customer_first_name; $p->fclast = $foxyResponse->transaction->customer_last_name; $p->fcprice = $foxyResponse->transaction->order_total; $p->fcproduct = $foxyResponse->transaction->transaction_details->transaction_detail->product_name; $p->save(); echo $p->render(); } 2) In the Foxycart receipt template I use a bit of javascript to get the transaction id and send it with a hidden form and a hidden target iframe to avoid redirection.
  12. Of course, but do not give any credit to me, is just copied from the FoxyCart docs https://wiki.foxycart.com/v/1.1/transaction_xml_datafeed /Script by David Hollander, www.foxy-shop.com //version 1.0, 7/9/2012 //Set Globals and Get Settings $apikey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; //----------------------------------------------------- // TRANSACTION DATAFEED //----------------------------------------------------- if (isset($_POST["FoxyData"])) { //DECRYPT (required) //----------------------------------------------------- $FoxyData_decrypted = foxycart_decrypt($_POST["FoxyData"]); $xml = simplexml_load_string($FoxyData_decrypted, NULL, LIBXML_NOCDATA); //For Each Transaction foreach($xml->transactions->transaction as $transaction) { //This variable will tell us whether this is a multi-ship store or not $is_multiship = 0; //Get FoxyCart Transaction Information //Simply setting lots of helpful data to PHP variables so you can access it easily //If you need to access more variables, you can see some sample XML here: http://wiki.foxycart.com/v/1.1/transaction_xml_datafeed $transaction_id = (string)$transaction->id; $transaction_date = (string)$transaction->transaction_date; $customer_ip = (string)$transaction->customer_ip; $customer_id = (string)$transaction->customer_id; $customer_first_name = (string)$transaction->customer_first_name; $customer_last_name = (string)$transaction->customer_last_name; $customer_company = (string)$transaction->customer_company; $customer_email = (string)$transaction->customer_email; $customer_password = (string)$transaction->customer_password; $customer_address1 = (string)$transaction->customer_address1; $customer_address2 = (string)$transaction->customer_address2; $customer_city = (string)$transaction->customer_city; $customer_state = (string)$transaction->customer_state; $customer_postal_code = (string)$transaction->customer_postal_code; $customer_country = (string)$transaction->customer_country; $customer_phone = (string)$transaction->customer_phone; //This is for a multi-ship store. The shipping addresses will go in a $shipto array with the address name as the key $shipto = array(); foreach($transaction->shipto_addresses->shipto_address as $shipto_address) { $is_multiship = 1; $shipto_name = (string)$shipto_address->address_name; $shipto[$shipto_name] = array( 'first_name' => (string)$shipto_address->shipto_first_name, 'last_name' => (string)$shipto_address->shipto_last_name, 'company' => (string)$shipto_address->shipto_company, 'address1' => (string)$shipto_address->shipto_address1, 'address2' => (string)$shipto_address->shipto_address2, 'city' => (string)$shipto_address->shipto_city, 'state' => (string)$shipto_address->shipto_state, 'postal_code' => (string)$shipto_address->shipto_postal_code, 'country' => (string)$shipto_address->shipto_country, 'shipping_service_description' => (string)$shipto_address->shipto_shipping_service_description, 'subtotal' => (string)$shipto_address->shipto_subtotal, 'tax_total' => (string)$shipto_address->shipto_tax_total, 'shipping_total' => (string)$shipto_address->shipto_shipping_total, 'total' => (string)$shipto_address->shipto_, 'custom_fields' => array() ); //Putting the Custom Fields in an array if they are there if (!empty($shipto_address->custom_fields)) { foreach($shipto_address->custom_fields->custom_field as $custom_field) { $shipto[$shipto_name]['custom_fields'][(string)$custom_field->custom_field_name] = (string)$custom_field->custom_field_value; } } } //This is setup for a single ship store if (!$is_multiship) { $shipping_first_name = (string)$transaction->shipping_first_name ? (string)$transaction->shipping_first_name : $customer_first_name; $shipping_last_name = (string)$transaction->shipping_last_name ? (string)$transaction->shipping_last_name : $customer_last_name; $shipping_company = (string)$transaction->shipping_company ? (string)$transaction->shipping_company : $customer_company; $shipping_address1 = (string)$transaction->shipping_address1 ? (string)$transaction->shipping_address1 : $customer_address1; $shipping_address2 = (string)$transaction->shipping_address1 ? (string)$transaction->shipping_address2 : $customer_address2; $shipping_city = (string)$transaction->shipping_city ? (string)$transaction->shipping_city : $customer_city; $shipping_state = (string)$transaction->shipping_state ? (string)$transaction->shipping_state : $customer_state; $shipping_postal_code = (string)$transaction->shipping_postal_code ? (string)$transaction->shipping_postal_code : $customer_postal_code; $shipping_country = (string)$transaction->shipping_country ? (string)$transaction->shipping_country : $customer_country; $shipping_phone = (string)$transaction->shipping_phone ? (string)$transaction->shipping_phone : $customer_phone; $shipto_shipping_service_description = (string)$transaction->shipto_shipping_service_description; } //Putting the Custom Fields in an array if they are there. These are on the top level and could be there for both single ship and multiship stores $custom_fields = array(); if (!empty($transaction->custom_fields)) { foreach($transaction->custom_fields->custom_field as $custom_field) { $custom_fields[(string)$custom_field->custom_field_name] = (string)$custom_field->custom_field_value; } } //For Each Transaction Detail foreach($transaction->transaction_details->transaction_detail as $transaction_detail) { $product_name = (string)$transaction_detail->product_name; $product_code = (string)$transaction_detail->product_code; $product_quantity = (int)$transaction_detail->product_quantity; $product_price = (double)$transaction_detail->product_price; $product_shipto = (double)$transaction_detail->shipto; $category_code = (string)$transaction_detail->category_code; $product_delivery_type = (string)$transaction_detail->product_delivery_type; $sub_token_url = (string)$transaction_detail->sub_token_url; $subscription_frequency = (string)$transaction_detail->subscription_frequency; $subscription_startdate = (string)$transaction_detail->subscription_startdate; $subscription_nextdate = (string)$transaction_detail->subscription_nextdate; $subscription_enddate = (string)$transaction_detail->subscription_enddate; //These are the options for the product $transaction_detail_options = array(); foreach($transaction_detail->transaction_detail_options->transaction_detail_option as $transaction_detail_option) { $product_option_name = $transaction_detail_option->product_option_name; $product_option_value = (string)$transaction_detail_option->product_option_value; $price_mod = (double)$transaction_detail_option->price_mod; $weight_mod = (double)$transaction_detail_option->weight_mod; } //If you have custom code to run for each product, put it here: } //If you have custom code to run for each order, put it here: //////// PW code is supposed to be here } //All Done! die("foxy"); //----------------------------------------------------- // NO POST CONTENT SENT //----------------------------------------------------- } else { die('No Content Received From Datafeed'); } //Decrypt Data From Source function foxycart_decrypt($src) { global $apikey; return rc4crypt::decrypt($apikey,urldecode($src)); } // ====================================================================================== // RC4 ENCRYPTION CLASS // Do not modify. // ====================================================================================== /** * RC4Crypt 3.2 * * RC4Crypt is a petite library that allows you to use RC4 * encryption easily in PHP. It's OO and can produce outputs * in binary and hex. * * © Copyright 2006 Mukul Sabharwal [http://mjsabby.com] * All Rights Reserved * * @link http://rc4crypt.devhome.org * @author Mukul Sabharwal <mjsabby@gmail.com> * @version $Id: class.rc4crypt.php,v 3.2 2006/03/10 05:47:24 mukul Exp $ * @copyright Copyright © 2006 Mukul Sabharwal * @license http://www.gnu.org/copyleft/gpl.html * @package RC4Crypt */ class rc4crypt { /** * The symmetric encryption function * * @param string $pwd Key to encrypt with (can be binary of hex) * @param string $data Content to be encrypted * @param bool $ispwdHex Key passed is in hexadecimal or not * @access public * @return string */ function encrypt ($pwd, $data, $ispwdHex = 0) { if ($ispwdHex) $pwd = @pack('H*', $pwd); // valid input, please! $key[] = ''; $box[] = ''; $cipher = ''; $pwd_length = strlen($pwd); $data_length = strlen($data); for ($i = 0; $i < 256; $i++) { $key[$i] = ord($pwd[$i % $pwd_length]); $box[$i] = $i; } for ($j = $i = 0; $i < 256; $i++) { $j = ($j + $box[$i] + $key[$i]) % 256; $tmp = $box[$i]; $box[$i] = $box[$j]; $box[$j] = $tmp; } for ($a = $j = $i = 0; $i < $data_length; $i++) { $a = ($a + 1) % 256; $j = ($j + $box[$a]) % 256; $tmp = $box[$a]; $box[$a] = $box[$j]; $box[$j] = $tmp; $k = $box[(($box[$a] + $box[$j]) % 256)]; $cipher .= chr(ord($data[$i]) ^ $k); } return $cipher; } /** * Decryption, recall encryption * * @param string $pwd Key to decrypt with (can be binary of hex) * @param string $data Content to be decrypted * @param bool $ispwdHex Key passed is in hexadecimal or not * @access public * @return string */ function decrypt ($pwd, $data, $ispwdHex = 0) { return rc4crypt::encrypt($pwd, $data, $ispwdHex); } } Just let me know if it works for you. I can´t get it working.
  13. Hello, Maybe not a PW directly related question, but just in case anyone has done it before: I'm triying to process the transaction data received from foxycart api, in a page/endpoint in PW. In this page there is a script such as: //Set Globals and Get Settings $apikey = "my api key"; //----------------------------------------------------- // TRANSACTION DATAFEED //----------------------------------------------------- if (isset($_POST["FoxyData"])) { //DECRYPT (required) //----------------------------------------------------- $FoxyData_decrypted = foxycart_decrypt($_POST["FoxyData"]); $xml = simplexml_load_string($FoxyData_decrypted, NULL, LIBXML_NOCDATA); //For Each Transaction foreach($xml->transactions->transaction as $transaction) { //This variable will tell us whether this is a multi-ship store or not $is_multiship = 0; //Get FoxyCart Transaction Information //Simply setting lots of helpful data to PHP variables so you can access it easily //If you need to access more variables, you can see some sample XML here: http://wiki.foxycart.com/v/1.1/transaction_xml_datafeed $transaction_id = (string)$transaction->id; $transaction_date = (string)$transaction->transaction_date; $customer_ip = (string)$transaction->customer_ip; $customer_id = (string)$transaction->customer_id; $customer_first_name = (string)$transaction->customer_first_name; $customer_last_name = (string)$transaction->customer_last_name; $customer_company = (string)$transaction->customer_company; $customer_email = (string)$transaction->customer_email; $customer_password = (string)$transaction->customer_password; $customer_address1 = (string)$transaction->customer_address1; $customer_address2 = (string)$transaction->customer_address2; $customer_city = (string)$transaction->customer_city; $customer_state = (string)$transaction->customer_state; $customer_postal_code = (string)$transaction->customer_postal_code; $customer_country = (string)$transaction->customer_country; $customer_phone = (string)$transaction->customer_phone; //Putting the Custom Fields in an array if they are there if (!empty($shipto_address->custom_fields)) { foreach($shipto_address->custom_fields->custom_field as $custom_field) { $shipto[$shipto_name]['custom_fields'][(string)$custom_field->custom_field_name] = (string)$custom_field->custom_field_value; } } } //For Each Transaction Detail foreach($transaction->transaction_details->transaction_detail as $transaction_detail) { $product_name = (string)$transaction_detail->product_name; $product_code = (string)$transaction_detail->product_code; $product_quantity = (int)$transaction_detail->product_quantity; $product_price = (double)$transaction_detail->product_price; $product_shipto = (double)$transaction_detail->shipto; $category_code = (string)$transaction_detail->category_code; $product_delivery_type = (string)$transaction_detail->product_delivery_type; $sub_token_url = (string)$transaction_detail->sub_token_url; $subscription_frequency = (string)$transaction_detail->subscription_frequency; $subscription_startdate = (string)$transaction_detail->subscription_startdate; $subscription_nextdate = (string)$transaction_detail->subscription_nextdate; $subscription_enddate = (string)$transaction_detail->subscription_enddate; //These are the options for the product $transaction_detail_options = array(); foreach($transaction_detail->transaction_detail_options->transaction_detail_option as $transaction_detail_option) { $product_option_name = $transaction_detail_option->product_option_name; $product_option_value = (string)$transaction_detail_option->product_option_value; $price_mod = (double)$transaction_detail_option->price_mod; $weight_mod = (double)$transaction_detail_option->weight_mod; } //If you have custom code to run for each product, put it here: } //If you have custom code to run for each order, put it here: $p = new Page(); $p->parent = $pages->get("1350"); $p->template = $templates->get("receipt"); $p->title = "Transaction id: ". $transaction_id; $p->save(); } //All Done! die("foxy"); //----------------------------------------------------- // NO POST CONTENT SENT //----------------------------------------------------- } else { die('No Content Received From Datafeed'); } //Decrypt Data From Source function foxycart_decrypt($src) { global $apikey; return rc4crypt::decrypt($apikey,urldecode($src)); } // ====================================================================================== // RC4 ENCRYPTION CLASS // Do not modify. // ===================================================================================== . . . ..script continues with the encryption, part of the code's been cut, just for clarity... The script captures a FoxyCart $_Post variable, decrypts it, and parses the XML data with SimpleXML and apparently works fine, as tested by Foxycart support, and returns ok ('foxy') to Foxycart servers. But the pages in PW are not created. Well, if the PW code is placed outside the foreach, not intended, it works but has no access to the PHP variables, eg $transaction_id number. Another weird thing, for me, is that every page that holds this script appears as "301 moved permanently" when requested the http headers, and maybe could be this the culprit ¿?. Well, as said before, just in case anyone here has done it before... Thanks in advance, Alejandro.
  14. Thank you Nik and Wanze (almost synchronized replies! ) It works as you both point. I think i have to read the API documentation paying more attention: http://processwire.com/api/types/nullpage/ So if I understand correctly, if " $fwd->id " is empty, NullPage is not returned.
  15. Hello, using the code $fwd = $pages->get("title=$transaction_id"); if($fwd) { $session->redirect($fwd->url); } else { $p = new Page(); $p->parent = $pages->get("1350"); $p->template = $templates->get("receipt"); $p->title = $transaction_id; $p->email = $email; $p->fcproduct = $product; $p->fcprice = $price; $p->save(); echo $p->render(); } I'm trying to generate a new page checkin if exists previosly. If exists is redirected correctly, if it doesn´t the page it's not created. But using just: $p = new Page(); $p->parent = $pages->get("1350"); $p->template = $templates->get("receipt"); $p->title = $transaction_id; $p->email = $email; $p->fcproduct = $product; $p->fcprice = $price; $p->save(); echo $p->render(); The page is created and rendered. I can´t get why the two pieces doesn´t like to be friends... Thanks in advance for any help, Alejandro
  16. I like it, ... includes svg fallback. Great documentation. Sold! Thank you for the link.
  17. Well, about the problematic field, finally I deleted it and created a new one and the problem is gone. Don´t know what was the fault with it, maybe some misconfiguration in the database ¿? Agree with you about tables + editor. I don´t like/trust the user to have too much control about the layout/format of the content. I found your module when searching for a different approach and think is quite a better solution, but the info I need to output has many combinations. A list of prices for products, but sometimes there is a price for several products (pages), promotions for 1 product or several... for example: The info comes from different product pages. So in the end i thought it would be easier to just let the user input a table. Mmm, still undecided. Thank you for your help.
  18. Hello, I´ve created a textarea field, type TinyMCE. When inserting a table and then saving the page, it disappears and it´s converted to a simple paragraph: Before saving: After saving: This happens with CKeditor as well, so maybe I´m missing something about the configuration of the field itself? Thanks.
  19. I really like this thread and what all you people are commenting. First, because I find more "newbies" like me, with similar difficulties but eager to learn. I love the support and dedication that experienced PWirers offer. And finally, i find that PW has kind of a "scalable learning curve", I mean actually I don´t fully understand it or some of the profiles of course... but i can do so many things and perform a lot of functionality with something as "simple" as: $page->get("name=123") echo "... or using the Related Pages Field. Uau! amazing, directly in the CMS, no need to add custom fields + plugin + then style it (where this class come from?!important) or something like that. I come from another CMS where I was for me so difficult to relate data, and i think that this is one of the main features a CMS should offer. So I settle here, and hope to reach far. Thanks
  20. Yep, i did it. I missed the field DBName... I've repeated the process assigning a pre-created database and works ok. Just one more question; do i need to create a new separate database for each site or may it be shared? Thank you Radek
  21. First of all, disclosure: using Mamp and Sequel pro for local development, but I don´t know much about Mysql, apache or databases I was developing a site locally, mainly to learn PW. I run another PW installation to develop a different site and then the first one shows a 404 error for any page. I guess the second install broke or deleted the associated database? No big loss, but i'd like to know where the error could came from. Thank you!
  22. Didn´t know about that issue with MediaWiki but I thought it was strange to split the docs into different sources. I'd be great to have it all in the main site. I believe that for newcomers/newbies/starters, a detailed, comprehensive and easy to find documentation is invaluable; even more if you are a graphic designer and need baby steps to advance.
  23. Well, i found the reference to Page Field in the documents, is in the wiki. I was learning PW following the API and Videos docs, as there are no link to the wiki in the PW home. http://wiki.processwire.com/index.php/Main_Page
  24. Aaaaah, again a silly mistake... The field is named "Teacher"...wrote "teacher" in code... code is case-sensitive... error! I guess is time to sleep. Thanks and sorry for the dumb question. PD There is a video about Page field types, pointing to cities related pages, but only in the admin side, no code shown.
  25. Mmmm, again lost... In the template "Product" there is a Page field "Teacher", which lists the teachers pages. The page "Yoga" has assigned the template "Product" and selected a teacher. Then how could I output the related page in the Yoga page? $page->teacher; This outputs nothing... Can´t find a reference in the docs about this field type.
×
×
  • Create New...