Jump to content

kongondo

PW-Moderators
  • Posts

    7,379
  • Joined

  • Last visited

  • Days Won

    139

Everything posted by kongondo

  1. Hi @thibaultvdb, Thanks for your interest in Padloper 2. I have moved your question to its own topic. Yes, it should be possible to do this with Padloper 2, although the feature is not available out of the box. There are at least two approaches I can think off. Let me sleep on it. I'll give you a better response tomorrow. Thanks.
  2. Hi @ank, Apologies for the late response. Below are examples of 'add to cart' buttons without page reload. Ajax is used to submit the request and handle the response from the server. There are two examples: jQuery ajax Vanilla JavaScript ajax In both cases, the server (Padloper) returns a JSON response. This is unlike in htmx in which case the server will return markup as the response. Hence, in the examples below, we need to handle the response ourselves. I have given some examples but you can choose to handle the response however you wish. The most important thing is the submission aspect of the code, i.e. what form inputs you send to the server. I'll explain these below before I get to the examples. In future, I will add the examples below to the demos repository. I will also be adding the explanations below to the docs. Add to Cart Endpoint You need to send a POST request to the address /padloper/add/. Padloper listens to requests sent there using URL Hooks. INPUTS Required Product ID (integer) Your request must contain the ID of the product you want to add to the cart. Please note that this applies to both a product without variants or a variant. I.e., in case of a variant, you only need to send its ID. Its ID will be its product ID. The input name must be: product_id Optional Quantity (integer) This tells Padloper how many of the given product/product variant to add to the cart. If this is not specified, it defaults to 1 item. The input name must be: padloper_cart_add_product_quantity Redirect Page (string | integer) This is only applicable for non-ajax requests! This tells Padloper where to redirect the user to after they add an item to the cart. It is useful in cases such as 'add to cart and checkout'. The value can be a string representing the URL to redirect to or a page ID whose URL to redirect to. The input name must be: padloper_cart_redirect EXAMPLES Notes These examples assume you are using a delayed output template strategy. Otherwise, if using a direct output you just need to echo $content. Please also note that form markup can be added to any page. You don't need a special page to add an item to the cart. Padloper products pages live under the admin hence cannot be accessed directly from the frontend. One way to show a product in the frontend is to access it via a URL Segment, e.g. /products/my-nice-product/ OR /products/1234/ where 1234 is the ID of the product. You can then use $padloper->get("id=1234") OR $padloper->get("name=my-nice-product, template=product"). We are using Tailwind CSS in our examples. For the jQuery example, you will need to link to jQuery script somewhere in your <head> or <body>. In this examples, we don't show how to use the values in the JSON in the server response. They are self-explanatory though. If not, let me know. The JavaScript handlers code was not thoroughly tested. They are intended as a quick illustration. jQuery Example Template File (PHP) JavaScript Vanilla JavaScript Example Template File (PHP) JavaScript Server Response { "productId": 1895, "variationId": 0, "productTitle": "Printed Ghanain Skirt", "quantity": 1, "totalQty": 85, "numberOfTitles": 5, "totalAmount": "\u00a313,425.45" } Please note that the variationId is a legacy response value that is no longer needed in Padloper. It will be removed in the next release. Screenshots Please note that in my testing, I combined the code for jQuery and Vanilla JavaScript into one template file. Demo Product Page Dev Console: Ajax Request Dev Console: Ajax Response Hope this helps. Otherwise, give us a shout. Cheers
  3. Hi @Stefanowitsch, I totally agree with your sentiments. The state of Padloper documentation is not good at all. I don't want to make excuses. Written documentation was at the top of my list but other things came up. I then decided to instead create video documentation. I started on those but again was sidetracked. Great! Happy to help you with this. This doesn't mean I won't be working on the video documentation; I'll still work on that. Technically, this is incorrect. Although there are a lot of new features and a new API, some aspects of Padloper 1 remain, e.g. 'padloper templates' to customise markup, e.g. summary of order line items in the basket, etc. Actually, you can. For instance, stuff like 'add to cart', 'checkout form', etc. are near identical. I am entirely to blame for this. As stated, the docs are not nearly good enough. They are actually still in an interim location. The plan has been to move them to the padloper domain. True. Again, I am to blame for this state. I will be covering this in the video docs. It is quite easy to create categories and products. Meanwhile, I can grant you backend access to the demo site to visualise how things work. Zero fields are required 😀. Padloper ships with its own custom fields in many cases. It also utilises a few in-built ProcessWire fields such as title and rich text area (for product descriptions). Padloper creates all fields for you during installation. At installation, you choose the features you want. For instance, if you don't want the feature 'category', Padloper will not install its related template(s) and fields. If you installed the feature 'tags' and later changed your mind, Padloper will remove this cleanly for you. Most features are optional. The core features include order and product. This is how I have planned the video docs. I.e., several short videos covering installation, setting up the backend, creating your first product, displaying products in the frontend, checkout, extending Padloper, etc. I understand your frustration. I agree, the docs need to provide this information. The video docs will do this. Meanwhile, I need to update the demo repos to indicate their incompleteness. This is a great suggestion, thanks! Somebody else mentioned this recently. My plan now is to include an option during installation to install a demo shop. This would match the features that you have selected for install. I also plan (not sure about the timeline for this) an integrated JavaScript driven backend demo of how things work in the backend, basically a click-through thing. Apologies the docs are not clear. Now that you point this out I see how they can be misleading and how they are incomplete. The above instructions are only for the demos. You don't need those templates for Padloper to work. You don't need to create any fields. For frontend use, the only thing that is required is a checkout page. Using the Padloper API ($padloper), you can access and display any Padloper items in the frontend wherever you like. You don't need a products page or a categories page, etc. For instance, you could display all your products on the homepage, etc. You could add items to your cart in a modal, or in a dedicated page, or however you want. At the end of the day, things are just ProcessWire pages. Technically, you can access things using ProcessWire API but $padloper saves you a few steps. I hope I have addressed all your queries. The above responses are not a substitute for good, quality documentation. Video documentation and better demo repos are still a high priority for me. Thanks for honestly pointing out the current shortcomings and your frustrations. Whether or not you decide to use Padloper, I genuinely value your opinion 🙂. Thanks!
  4. Tailwind Connect 2023: Recap of our first in-person event https://tailwindcss.com/blog/2023-07-18-tailwind-connect-2023-recap
  5. Hi @ank, Padloper can handle both ajax (no page reload) and non-ajax (page reload) requests. Please see the example projects in this repo: https://github.com/kongondo/Padloper2Starter With respect to ajax, Vanilla JS and jQuery examples are not complete. However, the htmx (Demo 1, etc.) examples are complete. Please have a look and let me know how you get on. I am planning to add some simpler examples some time soon. Thanks.
  6. What the others have said. Just noting here that the Web APIs have a Screen Capture API. Here's a CodePen.
  7. Hi @csaggo.com, I was looking forward to a showcase 😄 . Excellent! Congrats! Thanks for reporting. Yes, I noticed these a few weeks ago and fixed the code. The fixes will be available in the next release. I have something similar in the code fix, i.e. $configs=[]. True. All already have the fix per your description. Thanks!
  8. Hey @David Karich. No, nothing new I am afraid. A few unrelated stuff came up that I have had to focus on. This should be over in the next 2-3 weeks after which I'll resume the work on MM.
  9. Hi @Roadwolf, Just saying hello and welcome to ProcessWire and the forums 🙂.
  10. I see. I'll have a think about how devs can pass configs to the Stripe payment element. I think you should also confirm with Stripe/authorities that removing those fields will not go against the regulations for your country (including your customers' countries).
  11. Hi @Spinbox, This seems to be something injected by Stripe based on your settings in your Stripe dashboard. I don't see name inputs in my tests. Below is a screenshot of my Stripe payment fields: Could you check your dashboard settings please and let me know? Thanks.
  12. Aha! Thanks @bernhard. I wasn't aware you'd found a non-blocking solution. Thanks!
  13. Code GPT Visual Studio Code extension that lets you generate code from plain text within the editor using the official OpenAI API or other AI providers such as Google PaLM 2. https://marketplace.visualstudio.com/items?itemName=DanielSanMedium.dscodegpt https://codegpt.co/
  14. Thanks for this @Robin S. Maybe this technique can be used to achieve a non-blocking SSE? @bernhard, what do you think? I haven't thought it through; just wondering ATM. For reference:
  15. Hi @nabo, Many thanks for the purchase! I'll work on these; the fixes seem straightforward enough. I'll send you the updated files for testing and look to make an official release for later in the year. I hope this is OK. Thanks!
  16. Very! I have tested your code (verbatim) with both Stripe and Invoice payments and emails are sent in both cases! Maybe your first one (Invoice) ended up in the ether? I am assuming you checked your junk folder.
  17. Hi @Jan Fromm, I can confirm that this is a bug. I have it fixed in my current dev version. I am hoping to make that the next release of Padloper. I hope to do this pretty soon. Hopefully it isn't too late for your needs. Please let me know if it is. Thanks.
  18. Hi @alexm, Exactly. An example: <?php namespace ProcessWire; public function setAddonPage(Page $page, string $addonSettingsFieldName) { // here we assign these variables to class properties for convenience // you don't have to do that // you can use $page directly to get your settings using 'addonSettingsFieldName' $this->addonPage = $page; $this->addonSettingsFieldName = $addonSettingsFieldName; // -------- // EXAMPLE $addonSettingsJSON = $page->get($addonSettingsFieldName); bd($addonSettingsJSON, __METHOD__ . ': $addonSettingsJSON at line #' . __LINE__); if(!empty($addonSettingsJSON)){ $addonSettingsArray = json_decode($addonSettingsJSON,true); // do something with $addonSettingsArray } } I thought I had a hello world addon example in the demo projects. Looks like I don't. I'll add that to my TODO.
  19. 1 means that $mail sent 1 message. So, we know that that succeeded. Hmm. I am at a loss about this one. Given that the hook is called an an email is sent, I have no reason to suspect that the hook is perhaps being called late. Do you know if the customer is getting the email being sent by Padloper for this same order? Secondly, just for testing could you please test with Hooking before? Are you able to please test the exact same Hook function but by hooking to another method, e.g. ___saveOrder()? Thanks.
  20. Hey @alexm, the value of that would have to be 'custom'. All non-payment addons must be of type 'custom'. Yes. Sorry about that. I need to state that in the docs. Does this mean your question above about 'getType()' is now sorted? Thanks.
  21. Hey @alexm, Please clarify this. Does it mean the hook is not getting called or does it mean it is returning early (e.g. no $orderPage->id) or email not getting sent or email not getting received 😀. If you did $sent = $mail->send(); and dumped $sent, what do you get back?
  22. Morning @alexm, Apologies for the confusing docs (and perhaps naming issues). All non-payment addons must return 'custom' for getType(). Payment addons, even custom ones, are not defined as 'custom' addons. They are defined as payment addons and must return 'payment' for getType(). So, the idea of 'custom' does not mean 'third-party' or 'non-core'. Instead, it means the addon does something that is not necessarily a feature of Padloper, i.e. it does something custom. Since 'payment' is something that is a feature of Padloper, even third-party payment modules are not considered 'custom' since their function/role is to do something that is part of the core function of Padloper, i.e. payments. Hope this makes sense. Will revise docs.
  23. @alexm. Sorry, my bad! I get you now. I'll add this to the settings together with your other idea about a 'from email address'. I'll make a variable, $storeDetails or something like that available to invoice-content-html.php. This will give you access to the bank details saved in the store config. Do you need more than these three pieces of info? Cheers.
  24. Hi @Spinbox. This is coming in the next version (hopefully next week, there are quite a number of changes to it, so it is taking a bit of time). Meanwhile, do you mind using a Hook? I can show you how. Thanks.
  25. @Spinbox. Glad you got it sorted! Things look sanitized correctly. Did you see this topic as well? The docs state that InputfieldPassword::isValidPassword() (https://processwire.com/api/ref/inputfield-password/is-valid-password/: This means that it will use the password requirements set in the backend for ProcessWire users. If that suits your needs, then you could use the method as described in the post I have linked to above. If not, i.e. if you have a different set of requirements, you might have to roll out your own validation. An example is shown in the post I have linked to above. I think you should be fine with matching the requirements sent in the backend (i.e., use InputfieldPassword::isValidPassword() as is). You would need to handle cases where the password is found to be invalid (per your requirements). Hope this helps.
×
×
  • Create New...