Jump to content

adrianmak

Members
  • Posts

    533
  • Joined

  • Last visited

Everything posted by adrianmak

  1. Any real example? A few of screen captures are much appreciated.
  2. Without, padloper, it is still not that difficult to implement such an order inquiry said from OP create product template as usual implement shopping cart function (session based is the most easiest to implement). You canfind such php code snippnet around the Internet easily. Create a Order inquiry form, in which it will fetch the content from shopping cart.That's it.
  3. The profields pagetable has been around in core for some time. I just started playing around it. What is the purpose of a pagetable with more than one template ? In my testing, with a pagetable configured for more than one template, as show below Two add buttons will show on the pagetable field. Could you guys give me an example or scenario to describe when to use multiple templates?
  4. From second screen cap, how to make the invoice number (i.e.title field) not editable ?
  5. I'm curious, the /site/ready.php is not executed. is there any other settings to activated it ?
  6. Besides of my last question, I followed the op's setup, but it didn't work at atll This is my /site/ready.php instead of invoice, i changed it to order <?php function isOrderTemplate($template) { return ($template == 'order'); } $pages->addHookBefore("Pages::setupNew", function($event) { $page = $event->arguments(0); $is_order = isOrderTemplate($page->template); $no_inv_num = $page->title == ''; if ($is_order && $no_inv_num) { $counter_name = 'ORDER-' . date('Y'); $number = $this->modules->get('DatabaseCounters')->next($counter_name, 10, 5000); $page->title = $counter_name . '-' . sprintf("%06u", $number); } }); $pages->addHookAfter("ProcessPageEdit::loadPage", function($event) { $page = $event->return; $is_order = isOrderTemplate($page->template); $is_temp = $page->hasStatus(Page::statusTemp); if ($is_order && $is_temp) { $page->removeStatus(Page::statusTemp); $event->return = $page; } }); When I checked back the DatabaseCounter module config, there is no such a counter named ORDER- was created
  7. Question of setupNew page hook $pages->addHookBefore("Pages::setupNew" Instead of creating page at the pw's back-end admin ui, will this page hook be executed if I create a page thru api manually ?
  8. That is my first time to create an ecommerce site and it is a multi-language website too. I found that, for a PW's multi-language field, say title field any reference to that field, i.e. $product_name = $page->title; In front-end user point of view, it is just a plain text. However when digging into code level, there are are multi-language related properties are stored too. For just an CMS, there is no such a problem. But when it is dealing with paypal payment, when preparing a payment order items. For example, $PaymentOrderItems = array(); foreach($_SESSION['shopping_cart']['items'] as $cart_item) { $Item = array( 'name' => $cart_item['name'], // Item name. 127 char max. 'amt' => $cart_item['price'], // Cost of item. 'number' => $cart_item['id'], // Item number. 127 char max. 'qty' => $cart_item['qty'], // Item qty on order. Any positive integer. ); array_push($PaymentOrderItems, $Item); } The $Item['name'] will also have the mult-language field information. With this pw's behavior, is there any problem on the paypal side ? Will paypal can read the texture information only ?
  9. solved by myself. There should be a trailing slash. i.e. /setexpresscheckout/
  10. Submission form <?php $content = ''; $out = ''; $out .= "<div class='row'>"; $out .= "<div class='col-xs-12'>"; $out .= "<form id='payment-method' method='POST' action='/setexpresscheckout' role='form'>"; $out .= "<div class='radio'>"; $out .= "<label><input type='radio' name='payment_method' value='paypal' checked='checked'>Paypal</label>"; $out .= "</div>"; $out .= "<div class='radio'>"; $out .= "<label><input type='radio' name='payment_method' value='creditcard'>Credit Card</label>"; $out .= "</div>"; $out .= "<div class=''>"; $out .= "<input type='submit' value='Checkout' class='btn btn-success btn-lg' name='checkout' value='Checkout' />"; $out .= "</div>"; $out .= "</form>"; $out .= "</div>"; $out .= "</div>"; $content .= $out; The form processing template page <?php $content = ''; $content .= $input->post->payment_method; Empty/blank value from posted value If I changed the form action to self submission, i.e. $out .= "<form id='payment-method' method='POST' action='./' role='form'>"; I could get the value on the same form.
  11. I could find for pageName only from api doc http://processwire.com/api/variables/sanitizer/
  12. After a over half day work, the cart issue is solved by myself.
  13. Should I use in_array() to checks if a value exists in $session->cart_item ? The array structure like Array ( [1106] => Array ( [name] => LanguagesPageFieldValue Object ( [data:protected] => Array ( [1013] => 測試產品2 [1015] => [1016] => ) [defaultLanguagePageID:protected] => 1013 [field:protected] => Field Object ( [settings:protected] => Array ( [id] => 1 [type] => FieldtypePageTitleLanguage Object ( [allowTextFormatters:FieldtypeText:private] => 1 [data:protected] => Array ( ) [useFuel:protected] => 1 [className:Wire:private] => FieldtypePageTitleLanguage [classNameOptions:Wire:private] => Array ( ) [localHooks:protected] => Array ( ) [trackChanges:Wire:private] => 0 [changes:Wire:private] => Array ( ) [_notices:protected] => Array ( [errors] => [warnings] => [messages] => ) ) [flags] => 13 [name] => title [label] => Title ) [prevTable:protected] => [prevFieldtype:protected] => [trackGets:protected] => [viewRoles:protected] => Array ( ) [editRoles:protected] => Array ( ) [data:protected] => Array ( [required] => 1 [textformatters] => Array ( [0] => TextformatterEntities ) [size] => 0 [maxlength] => 255 ) [useFuel:protected] => 1 [className:Wire:private] => [classNameOptions:Wire:private] => Array ( ) [localHooks:protected] => Array ( ) [trackChanges:Wire:private] => 2 [changes:Wire:private] => Array ( ) [_notices:protected] => Array ( [errors] => [warnings] => [messages] => ) ) [useFuel:protected] => 1 [className:Wire:private] => [classNameOptions:Wire:private] => Array ( ) [localHooks:protected] => Array ( ) [trackChanges:Wire:private] => 2 [changes:Wire:private] => Array ( ) [_notices:protected] => Array ( [errors] => [warnings] => [messages] => ) ) [id] => 1106 [quantity] => 1 [price] => 265 ) ) My code for checking if an item exists in cart item $cart_item = $session->cart_item; if(in_array($itemArray[$product->id], $cart_item)) { // do something $a = "update existing product item in cart_item."; } else { // do something else $a = "Add product item into cart."; } I always return false. ie no match
  14. The code I pasted is just preliminary. I always use sanitizing inputs in my final version.
  15. How to update an existing session variable ? A session variable cart_item has such a array structure Array ( [10] => Array ( [name] => product-10 [id] => 10 [quantity] => 10 [price] => 250 ) ) For testing and debugging, I tried to update the quantity manual $session->cart_item[10]['quantity'] = 20; Then, I printed again the cart_item session variable, it's quantity is still 10
  16. I tried to put folllowing code at the end of product template file $content .= count($session->cart_item); if(isset($session->cart_item)) { $content .= "session existed"; } else { $content .= "session non-existed"; } count shown 1 but the if statement return false. "sessoion non-existed" is appended
  17. I tried to use isset in place of !empty(), but it still not working. My scenario is adding a product to cart thru ajax here is my code server side php ajax for adding item into session variable <?php // ProcessWire bootstrap include('./index.php'); $a = ''; if(wire('config')->ajax) { $action = $_POST['action']; $product_id = $_POST['product_id']; $quantity = $_POST['quantity']; if(!empty($action)) { switch($action) { case "add": if(!empty($quantity)) { $product = $pages->get($product_id); $itemArray = array($product->id => array('name' => $product->title, 'id' => $product->id, 'quantity' => $quantity, 'price' => $product->price ) ); if(isset($session->cart_item)) { // session variable existed if(in_array($itemArray, $session->cart_item)) { foreach($session->cart_item as $key => $value) { if($itemArray == $key) $session->cart_item[$key]["quantity"] = $quantity; } } else { $session->cart_item = array_merge($session->cart_item, $itemArray); $a = "NEW"; } $a = "NEW item added"; //$session->set("cart_item", $itemArray); } else { $session->set("cart_item", $itemArray); } } break; case "remove": break; break; } echo "OK" . " " . $a; } } else { echo "cannot execute the script directly."; } The js script //$(document).ready(function () { function cartAction(action, product_id) { var queryString = ""; if(action != "") { switch(action) { case "add": queryString = 'action='+action+'&product_id='+product_id+'&quantity='+$("#quantity").val(); break; case "remove": queryString = 'action='+action+'&product_id='+product_id; break; break; } } console.log(queryString); jQuery.ajax({ url: "/cart_ajax.php", data: queryString, type: "POST", success: function(data) { console.log(data); } }); } //}) the product detail template <?php $content = ""; $out = ""; $header_image = ''; $js = ''; $js .= "<script src='{$config->urls->templates}assets/js/cart.js'></script>"; // render product details $out = wireRenderFile("partial/product-details-tpl", array('product'=>$page)); $content .= $out; product detail render template <?php $out = ""; $out .= "<div class='product-detail'>"; $out .= "<form class='formCart'>"; $out .= "<div id='product' class='row list-group'>"; $out .= "<div class='col-xs-5 col-lg-5'>"; $out .= "<div class='thumbnail'>"; $out .= "<img class='group list-group-image' src='{$product->product_img->url}' width='100%' alt='' />"; $out .= "</div>"; $out .= "</div>"; $out .= "<div class='col-xs-7 col-lg-7'>"; $out .= "<input type='hidden' name='product-id' value='{$product->id}' />"; $out .= "<div class='product-title'><h2>{$product->title}</h2></div>"; $out .= "<div class='product-price'>HKD {$product->price}</div>"; $out .= "<div class='product-desc'>{$product->body}</div>"; $out .= "<div class='product-quantity'>"; $out .= "<label for='quantity'>Quantity:</label>"; $out .= "<select class='form-control' id='quantity' name='quantity'>"; $out .= "<option value='1' selected>1</option>"; $out .= "<option value='2'>2</option>"; $out .= "<option value='3'>3</option>"; $out .= "<option value='4'>4</option>"; $out .= "<option value='5'>5</option>"; $out .= "<option value='6'>6</option>"; $out .= "<option value='7'>7</option>"; $out .= "<option value='8'>8</option>"; $out .= "<option value='9'>9</option>"; $out .= "<option value='10'>10</option>"; $out .= "</select>"; $out .= "</div>"; $out .= "<div class='add-to-cart'>"; $out .= "<input class='btn btn-primary btn-lg' name='submit' type='button' value='Add to cart' onclick=\"cartAction('add', '{$page->id}')\" />"; $out .= "</div>"; $out .= "</div>"; $out .= "</div>"; $out .= "</form>"; $out .= "</div>"; echo $out;
  18. here is my snippet of code if(!empty($session->cart_item)) { // session variable existed and to update session variable content } else { // add new session variable $session->set("cart_item", $itemArray); } I found that the if statement always false. Should I use the wrong way for checking an existence of session variable ?
  19. A client want to develop a new service booking system to replace the old one (php). It's not that difficult to develop it , but the key is how to transfer/import user account from the old system ? Each account has a password field and it's encrypted.
  20. I think LostKobrakai suggestion is more likely to fit my case
  21. When editing a page content, the client want to receive visitor enquiry. For example, a piece of content may looks like, Duis scelerisque cum enim ut ullamcorper feugiat augue aptent a eu cursus faucibus a a ullamcorper ac condimentum commodo ornare venenatis ad sed ac proin consectetur penatibus. Sapien a curae senectus vestibulum ornare consectetur cursus consectetur egestas id dictum venenatis nisi eu odio conubia lacus. Pulvinar a rutrum mi mi nostra id sed vestibulum luctus pharetra a cubilia vestibulum vehicula scelerisque himenaeos class a viverra parturient metus ad a porttitor. Adipiscing nunc proin inceptos in sodales fringilla arcu sem adipiscing vehicula euismod hendrerit eget blandit。 Please contact ask thru info@example.com or info@xyz.com Then I built an enquiry form for client, the client could make the email address as hyper link, link to the enquiry form page i.e. <a href="/enquiry">info@example.com</a> or <a href="/enquiry">info@xyz.com</a> The problem is, I hard-coded both email addresses in the code of the enquiry page template. Clicking either info@example.com or info@xyz.com, the form data will be sent to both email addresses. The client does not want this behaviour .
  22. Module should add additional permissions automatically.
  23. I'm going to build a simple e-commerce website. I knew there ise-commerce pw module to do the job. I want to build it from scratch. One of a page template will be order. An order may have more than one product item Which field type (repeaters, page, any others ?) is the best for repeating item on this case.
×
×
  • Create New...