Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by adrianmak

  1. $page variable is working find in phpstorm However, there is no code autocomplete for other variables like $session, $pages, $users, $user, etc
  2. I'm not sure how to set it up. When specify a destination, it could only select a page from page tree or something like page:1017 1017 is the page id but how to specify page id 1017 of other language ?
  3. Thank you Ryan for my code adjustments commented on the github. The issue is resolved. I posted the complete code snippet with Ryan's code adjustment // Add a customer order in database $orders = $pages->get(1152); $p = new Page(); $orderByUser = $user; $p->template = "order"; $p->parent = $orders; $counter_name = $order_number_prefix . date('Y'); $number = $this->modules->get('DatabaseCounters')->next($counter_name, 1, 5000); $ordernumber = $counter_name . '-' . sprintf("%06u", $number); $p->of(false); $def = $wire->languages->get("default"); $chs = $wire->languages->get("chs"); $eng = $wire->languages->get("eng"); $p->title->setLanguageValue($def, $ordernumber); $p->title->setLanguageValue($chs, $ordernumber); $p->title->setLanguageValue($eng, $ordernumber); $p->order_number = $ordernumber; $p->member = $orderByUser; $p->payment_method = $session->get("payment_method"); $p->order_time = $session->get("order_time"); $p->paypal_transaction_id = $session->get("paypal_transaction_id"); foreach($languages as $lang) $p->set("status$lang", 1); $p->save(); foreach($session->get("cart_item") as $cart_item) { $item = $p->items->getNew(); foreach($languages as $lang) $item->set("status$lang", 1); $item->product_id = $cart_item['id']; $item->product_price = $cart_item['price']; $item->product_quantity = $cart_item['quantity']; $item->save(); $p->items->add($item); $transaction_amount += ($cart_item['price'] * $cart_item['quantity']); } $p->transaction_amount = $transaction_amount; $p->save();
  4. How to deal with multi-language website ? A client with a old website build with joomla A multi-language url may look like for a same piece of content content/blogcategory/19/34/lang,en/ content/blogcategory/19/34/lang,zh/ content/blogcategory/19/34/lang,gb/ How to redirect to different language of a pw site ?
  5. I think it is more easily to manage multilanguage strings translation, as I don't need to login at the back-end to do that job
  6. As soma said in #4, it is good to use an external php file for multilanguage string translation, and include in some where instead of do it by pw. $translation_strings['default'] = array( 'MESSAGE-1' => "this is english message", 'MESSAGE-2' => "this is english message 2", 'MESSAGE-3' => "this is english message 3", 'MESSAGE-4' => "this is english message 4 ", 'MESSAGE-5' => "this is english message 5", ) translation_strings['japan'] = array( 'MESSAGE-1' => "これは、日本のマッサージ", 'MESSAGE-2' => "これは、日本のマッサージ2", 'MESSAGE-3' => "これは、日本のマッサージ3", 'MESSAGE-4' => "これは、日本のマッサージ4", 'MESSAGE-5' => "これは、日本のマッサージ5", ) Then include in _init.php in a page template, something like $text = $translation_strings[$user->language->name]; //do something $content .= $text['MESSAGE-4'];
  7. I tried to delete the old order template and repeater field, and to create both a new one. Issue is still existed. Anyway, I have posted an issue on github https://github.com/ryancramerdesign/ProcessWire/issues/1790
  8. If ESRCH could replicate the same issue, then we can ensure there is a bug in between repeater field and multi-language
  9. By the way, I did find other people has similar issue on repeater field on multilanguage site https://processwire.com/talk/topic/11300-problem-with-repeater-fields-in-multi-language-pages/ https://processwire.com/talk/topic/11732-repeater-fields-not-displayed-on-non-default-language-page/?hl=repeater Unfortunately, they didn't get a solid answer or find out what caused that problem.
  10. product template order_items repeater field Which version of Processwire are you using ? >2.7.3 What are the fields types of the fields on the product template > See the above screen cap When you create an order on the English backend, and then view the order in the back-end in English (by setting your profile language to English), do the order items appear? > No matter which language used in user profile, creating an order in back-end ui directly, All items can shown in all languages. ps I used admin to create an order. other user role has no permission to created an order thru the back-end. Do you have the same problem if you create the order in the chs front-end ? Do the order items then not appear in Chinese simplified, but appear in English and default languages ? > no matter using chs or english front-end language for the whole order purchase, order item shown on default language only.
  11. instead of using below code to create a page table row $newpage = $pages->add('basic-page', '/about/', 'address', array('title' => 'Write to us')); could i use the traditional way of creating a new page ? ie. $pt_parent = $pages->get('/page-table-parent'); $p = new Page(); $p->template = "page-table-template"; $p->parent = $pt_parent; $p->title = "page table title"; $p->body = "page table body"; $page->of(false); $page->page_table_field->add($p);
  12. I put a site settings toggle to turn on/off for front-end user login if it is on, the login form will not show and with a message something like "Site under maintenance. User login is temporary closed" I found that is a user is already login and visit those restricted area (required user log-in), and I turn off user login, those logged in users are still able to visit the restricted area. How (possible?) do I kill all logged in users' session ?
  13. Show u some screen cap of my current working site. Instead of checking out to paypal payment, just show with an order form here. That all.
  14. Is there any time duration for the persistent login ?
  15. My client just asked me want to put a Remember Me checkbox on custom front-end user login form. As I knew PW is member a user login, so a checkbox is not necessary in PW. But I want to know how long does pw keep a user login session ?
  16. Tried your suggestion. Worst than before This time only the default language get a count from order items Settting a parent did not help.
  17. $order->order_items->count(); Show a count only in default and chs. eng is returned zero
  18. This is the template to list all the order that current $user had made <?php $_heading = __("交易記錄"); // Order history $_tbl_header_1 = __("訂單號碼"); // Order number $_tbl_header_2 = __("PayPal交易號碼"); // paypal transaction id $_tbl_header_3 = __("交易日期"); // order date $_tbl_header_4 = __("交易金額"); // order amount $_no_history = __("沒有交易記錄"); // No order history $content = ''; $out = ''; $edit = ''; $header_image = ''; $rowcount = 1; $orders = ''; $breadcrumb = breadcrumb($page->id); if($user->isSuperuser() || $user->hasRole("editor")) $selector = "template=order, sort=-order_time"; else $selector = "template=order, member={$user}, sort=-order_time"; $orders = $pages->find($selector); $out .= "<div class='row clearfix'>"; $out .= "<div class='col-md-12'>"; $out .= "<h2>{$_heading}</h2>"; if($orders) { $out .= "<table class='table table-bordered table-condensed table-striped '>"; $out .= "<thead>"; $out .= "<tr>"; $out .= "<th>#</th>"; $out .= "<th class='center'>{$_tbl_header_1}</th>"; $out .= "<th class='center'>{$_tbl_header_2}</th>"; $out .= "<th class='center'>{$_tbl_header_3}</th>"; $out .= "<th class='center'>{$_tbl_header_4}</th>"; $out .= "</tr>"; $out .= "</thead>"; $out .= "<tbody>"; foreach($orders as $order) { // Order detail modal popup $out .= "<div class='modal fade' id='orderDetail-{$order->id}' tabindex='-1' role='dialog' aria-labelledby='myModalLabel' aria-hidden='true'>"; $out .= "<div class='modal-dialog'>"; $out .= "<div class='modal-content'>"; $out .= "</div> <!-- /.modal-content -->"; $out .= "</div> <!-- /.modal-dialog -->"; $out .= "</div> <!-- /.modal -->"; $out .= "<tr>"; $out .= "<td class='center'>{$rowcount}</td>"; $out .= "<td class='center'><a data-toggle='modal' data-target='#orderDetail-{$order->id}' href='".$pages->get(1208)->url."?id=".$order->id."'>{$order->order_number}</a></td>"; $out .= "<td class='center'>{$order->paypal_transaction_id}</td>"; $out .= "<td class='center'>".date('d-M-Y', $order->order_time)."</td>"; $out .= "<td class='center'>".number_format($order->transaction_amount)."</td>"; $out .= "</tr>"; $rowcount++; } $out .= "</tbody>"; $out .= "</table>"; $out .= "</div>"; $out .= "</div>"; $content .= $out; } else { $content .= $_no_history; } $out .= "<td class='center'><a data-toggle='modal' data-target='#orderDetail-{$order->id}' href='".$pages->get(1208)->url."?id=".$order->id."'>{$order->order_number}</a></td>"; The is 1208 is the page id of a order detail modal box, passing order is to this template This is the modal box order-details.php template <?php // translation string $_order_detail_text_1 = __("訂單號碼"); // Order number $_order_detail_text_2 = __("PayPal交易號碼"); // PayPal transaction id $_order_detail_text_3 = __("交易日期"); // Order time $_order_detail_text_4 = __("交易金額"); // transaction amount $_order_detail_text_5 = __("項目"); // Items $_order_detail_text_6 = __("會員"); // Member $_order_detail_text_7 = __("付款方法"); // Payment method $_tbl_header_1 = __("產品"); // product $_tbl_header_2 = __("售價"); // price $_tbl_header_3 = __("數量"); // quantity $_tbl_header_4 = __("總額"); // total $content = ''; $out = ''; $header_image = ''; $edit = ''; $oder = ''; $total = 0; $subtotal = 0; $order = $pages->get($input->get->id); // get order detail record if($input->get->id) { $out .= "<div class='order-detail-container'>"; $out .= "<p class='no-indent'><strong>{$_order_detail_text_6}: <strong>".$order->member->name."</p>"; $out .= "<p class='no-indent'><strong>{$_order_detail_text_1}: <strong>".$order->order_number."</p>"; $out .= "<p class='no-indent'><strong>{$_order_detail_text_2}: <strong>".$order->paypal_transaction_id."</p>"; $out .= "<p class='no-indent'><strong>{$_order_detail_text_3}: <strong>".date('d-M-Y', $order->order_time)."</p>"; $out .= "<p class='no-indent'><strong>{$_order_detail_text_4}: <strong>".number_format($order->transaction_amount)."</p>"; $out .= "<p class='no-indent'><strong>{$_order_detail_text_7}: <strong>".$order->payment_method."</p>"; $out .= "<h3>$_order_detail_text_5</h3>"; $out .= "<table class='table table-bordered'>"; $out .= "<thead>"; $out .= "<tr>"; $out .= "<th>{$_tbl_header_1}</th>"; $out .= "<th class='center'>{$_tbl_header_2}</th>"; $out .= "<th class='center'>{$_tbl_header_3}</th>"; $out .= "<th class='center'>{$_tbl_header_4}</th>"; $out .= "</thead>"; $out .= "<tbody>"; foreach($order->order_items as $item) { $p = $pages->get($item->product_id); $out .= "<tr>"; //$out .= "<td>{$item->product_name}</td>"; $out .= "<td>{$p->title}</td>"; $out .= "<td class='center'>{$item->product_price}</td>"; $out .= "<td class='center'>{$item->product_quantity}</td>"; $total = $item->product_price * $item->product_quantity; $out .= "<td class='center'>".number_format($total)."</td>"; $out .= "</tr>"; $subtotal += $total; } $out .= "</tbody>"; $out .= "</table>"; $out .= "</div>"; $content .= $out; } else { $session->redirect($homepage->url); }
  19. I have issue using repeater field in multi-language https://processwire.com/talk/topic/13098-pages-created-by-api-could-not-able-to-retrieve-from-other-languages/?p=118618
  20. As ESRCH suggested, I added another text field (not the multilanguage text field) for order number However I can only hide the original text field from ui and cannot deleted it (pw nature, title field is compulsory for all template) and the text field is configured as PageTitleLanguage (used by other page templates), then the order template is also a multilanguage . So I have to make other two languages active before saving. Here is my updated code // Add a customer order in database $p = new Page(); $orderByUser = $user; $p->template = "order"; $counter_name = $order_number_prefix . date('Y'); $number = $this->modules->get('DatabaseCounters')->next($counter_name, 1, 5000); $ordernumber = $counter_name . '-' . sprintf("%06u", $number); $p->order_number = $ordernumber; $p->member = $orderByUser; $p->payment_method = $session->get("payment_method"); $p->order_time = $session->get("order_time"); $p->paypal_transaction_id = $session->get("paypal_transaction_id"); foreach($session->get("cart_item") as $cart_item) { // create order items $item = $p->order_items->getNew(); $item->product_id = $cart_item['id']; $item->product_price = $cart_item['price']; $item->product_quantity = $cart_item['quantity']; $item->save(); $p->order_items->add($item); $transaction_amount += ($cart_item['price'] * $cart_item['quantity']); } $p->transaction_amount = $transaction_amount; $p->of(false); foreach($languages as $lang) { if($lang->isDefault()) continue; $p->set("status$lang", 1); $p->save(); } I found that the order_items (repeater field) does not display on English language until I edit that order at the back-end and save once again. There is no issue on default and chs language Here is a recorded youtube to show the issue I described.
  21. My site has three language, default, chs, eng. Default language is cht (traditional chinese) I have an order template (no output template). Structure look like An order will be created after a successful paypal transaction has been made. When I'm on default language, the order creation is working properly. However, if I switched to chs or eng The order number field i.e. title field cannot be inserted. I just saw an empty title field. All other fields are populated values properly, except the order number Here is my page creation code $p = new Page(); $orderByUser = $user; $p->template = "order"; $counter_name = $order_number_prefix . date('Y'); $number = $this->modules->get('DatabaseCounters')->next($counter_name, 1, 5000); $ordernumber = $counter_name . '-' . sprintf("%06u", $number); $p->title = $ordernumber; $p->member = $orderByUser; $p->payment_method = $session->get("payment_method"); $p->order_time = $session->get("order_time"); $p->paypal_transaction_id = $session->get("paypal_transaction_id"); foreach($session->get("cart_item") as $cart_item) { // create order items $item = $p->order_items->getNew(); $item->product_id = $cart_item['id']; $item->product_name = $cart_item['name']; $item->product_price = $cart_item['price']; $item->product_quantity = $cart_item['quantity']; $item->save(); $p->order_items->add($item); $transaction_amount += ($cart_item['price'] * $cart_item['quantity']); } $p->transaction_amount = $transaction_amount; $p->of(false); $p->save();
  22. I just built a simple shopping cart (added cart items are stored in session) and with paypal express checkout. it is working fine and tested in paypal sandbox. The product name is a multi-language field If i changed to another language on the website, when redirected to paypal checkout page, the product name is using my website's default language. the multi-language of the product name and desc. is display correctly in my website.
  23. In posted screenshot, the text column pagetable isn't fixed in 3 cols ? or it can be in any number of colums, 2, 3 or 4
  • Create New...