Jump to content

Gadgetto

Members
  • Posts

    394
  • Joined

  • Last visited

  • Days Won

    12

Posts posted by Gadgetto

  1. Hello,

    two days ago I filed a issue on GitHub regarding a problem I encountered while using TinyMCE, where TinyMCE field keeps modifying HTML markup which is pasted via code editor (code plugin) after saving the page a second time.

    The issue can be found here: https://github.com/processwire/processwire-issues/issues/1751

    Could someone please confirm if this is a bug in the TinyMCE field or just me having the problem?

    Thanks,
    Martin

    • Like 1
  2. Hello,

    I'm just trying to run this simple pages selector but it always leads to a DB timeout:

    $homePage = $pages->get('/'); // <-- this part works
    $sectionPages = $homePage->and($homePage->children()); // <-- leads to MySQL timeout
    
    // this also works (but then of course the home page is missing in the PageArray)
    $sectionPages = $homePage->children();

    I'd like to select the visible tree parts of this:

     image.png.cf8d09cf59af02fc4be7a3e6e2425cbd.png

    This is the full error message:

    [31-May-2023 21:49:52 Europe/Vienna] PHP Fatal error:  Exception: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away (in /wwwroot/wire/core/WireDatabasePDOStatement.php line 168)
    
    #0 /Users/mgartner/ProjekteWEB/bitego_2023/wwwroot/wire/core/WireDatabasePDOStatement.php(168): PDOStatement->execute(NULL)
    #1 /Users/mgartner/ProjekteWEB/bitego_2023/wwwroot/wire/core/WireDatabasePDOStatement.php(148): ProcessWire\WireDatabasePDOStatement->executeDebug(NULL)
    #2 /Users/mgartner/ProjekteWEB/bitego_2023/wwwroot/wire/core/WireDatabasePDO.php(936): ProcessWire\WireDatabasePDOStatement->execute()
    #3 /Users/mgartner/ProjekteWEB/bitego_2023/wwwroot/wire/core/PagesLoader.php(1309): ProcessWire\WireDatabasePDO->execute(Object(ProcessWire\WireDatabasePDOStatement))
    #4 /Users/mgartner/ProjekteWEB/bitego_2023/wwwroot/wire/core/Pages.php(1193): ProcessWire\PagesLoader->getById(Array, Object(ProcessWire\Template), 29)
    #5 /Users/mgartner/ProjekteWEB/bitego_2023/wwwroot/wire/core/PagesType.php(397): ProcessWire\Pages->getById(Array, Array)
    #6 /Users/mgartner/ProjekteWEB/bitego_2023/wwwroot/wire/core/Users.php(77): ProcessWire\PagesType->get(41)
    #7 /Users/mgartner/ProjekteWEB/bitego_2023/wwwroot/wire/core/Session.php(210): ProcessWire\Users->get(41)
    #8 /Users/mgartner/ProjekteWEB/bitego_2023/wwwroot/wire/core/ProcessWire.php(601): ProcessWire\Session->__construct(Object(ProcessWire\ProcessWire))
    #9 /Users/mgartner/ProjekteWEB/bitego_2023/wwwroot/wire/core/ProcessWire.php(315): ProcessWire\ProcessWire->load(Object(ProcessWire\Config))
    #10 /Users/mgartner/ProjekteWEB/bitego_2023/wwwroot/index.php(52): ProcessWire\ProcessWire->__construct(Object(ProcessWire\Config))
    #11 {main} in /wwwroot/index.php on line 64

    I'm using:

    • ProcessWire 3.0.218 dev
    • PHP 8.1.13
    • MySQL 5.7.39
    • the Database format is InnoDB

    What could be wrong here??

    Greetings,
    Martin

  3. On 10/21/2021 at 12:40 PM, DV-JF said:

    Hey @cjx2240

    I recognized that this behaviour only occurs when I inspect the website with the dev tools and the "user agent" is changed.

    To prevent this I added the following entry in the site/config.php file:

    /**
     * Prevent from being frequently logged out while using Chrome DevTools
     * 
     */
    $config->sessionFingerprint = 2;

    Hope this helps you too.

    To make it save for production you could check if $config->debug is true and wrap this with an if query-.

     

    Great find!

  4. 12 hours ago, doolak said:

    Another question: As you live in Austria - do you have any German Translation for it?

    Sorry, no German translation available. I'm planning to put the language package on Crowdin - but I need to figure out the best way to do this under ProcessWire.

    In MODX for example, all language strings are collected in single files...

    Edit:
    It seems since PW 3.0.181 it is possible to ship your modules with additional translation files inside a languages folder!

    • Like 1
  5. On 3/5/2020 at 10:39 PM, Robin S said:

    This is already possible with two lines of code, so I don't think a dedicated method is needed.

    $s = $modules->get('InputfieldSubmit');
    $s->attr('disabled', true);
    $s->addClass('ui-state-disabled');

     

    This doesn't work as expected because it only disables the <button> element. But ProcessWire embeds the <button> element within an <a> tag and a click will follow the href nevertheless. Additionally the button element doesn't look disabled... 

    I think InputfieldSubmit and it's siblings renders a strange kind of html. <button> within <a></a> is not valid HTML5 and could lead to unexpected behavior. I already filed an issue on GitHub but Ryan told its intended an can't be changed.

  6. 5 hours ago, bernhard said:

    Thx @Gadgetto

    my message was not meant as criticism. I just don't get WHY SnipWire does all that. Ok, I get that you need to setup some fields that hold necessary data (vat, description, image) and then you need to create the markup. That should be quite simple though without using SnipWire (for example using RockMigrations which you can guess I'm using in every project ? ). The cart-button could then look somewhat like this:

    
    <button
      class="snipcart-add-item uk-button uk-button-primary"
      title="Add to cart"
      aria-label="Add item to cart"
      data-item-name="<?= $page->title ?>"
      data-item-id="<?= $page->id ?>"
      data-item-price='<?= $page->price ?>'
      data-item-url="<?= $page->httpUrl ?>"
      data-item-description="<?= $page->description ?>"
      ...>
      <span uk-icon="icon: cart"></span> Add to cart
    </button>

    Ok... I get that's quite tedious and having a helper method for that could for sure be handy. What I still don't get is why you took all that effort to get all (or at least many?) of the features of snipcart into the pw backend? Wouldn't it be a lot easier if the clients just managed their snipcart shop via the snipcart website? As far as I understood the client has to register an account there and then gets a login where he/she can manage their products/sold items etc?

    It's obvious that SnipWire can do a lot and I'm quite impressed - I'm just not getting the WHY behind all that. Maybe it's just because I don't know anything of the PAIN you are solving because I've never setup a snipcart store manually...

    If you only need/want to render the Snipcart anchors/buttons then you could do it by simply using php and ProcessWire output (but for example handling VAT splitting and multi currency will be another thing).

    For all other things I listed above, SnipWire will do the job for you. 

  7. 1 hour ago, bernhard said:

    As I understood it's as simple as adding custom button markup to the site and you are up and running your snipcart site. The dashboard in this case would obviously be hosted at snipcart and not inside my processwire project, but is that the only reason for this module? I have the feeling that I must be missing something ? 

    • SnipWire integrates the Snipcart dashboard into your ProcessWire backend
    • SnipWire installs all necessary fields for setting up your products editor (> 22 different fields)
    • it automatically generates the necessary Snipcart anchor markup based on those fields
    • SnipWire provides an easy way to integrate the Snipcart shopping cart into your project (including cart button, customer profile, login, logout, ...)
    • provides sample templates to setup your online shop.
    • handles and calculates all of the different VAT handlings worldwide
    • handles multi currency
    • process refunds right from your ProcessWire back-end
    • process abandoned carts and send messages to customers right from the ProcessWire back-end
    • provides hookable ProcessWire events for orders, customer registration, ...
    • ...

    How would you handle the custom data attributes markup without an engine generating it? If you only have a handful products this might be possible by writing the markup by hand but if your client should be able to manage a shop, SnipWire is the best way to do it.

    As a sample - how would you do this manually?

    <button
      class="snipcart-add-item uk-button uk-button-primary"
      title="Add to cart"
      aria-label="Add item to cart"
      data-item-name="Festish Wet Warmer"
      data-item-id="1713"
      data-item-price='{"usd":"22.20","eur":"19.90"}'
      data-item-url="http://domain.com/snipcart-shop/festish-wet-warmer/"
      data-item-description="A short product description..."
      data-item-image="http://domain.com/site/assets/files/1713/beer2.65x65-hidpi.jpg"
      data-item-categories="Beer"
      data-item-metadata='{"id":1713,"created":1563363120,"modified":1580402487,"published":1563363120,"created_users_id":41,"modified_users_id":41}'
      data-item-quantity="1"
      data-item-quantity-step="1"
      data-item-stackable="true"
      data-item-taxable="true"
      data-item-taxes="10% VAT"
      data-item-has-taxes-included="true"
      data-item-shippable="true">
          <span uk-icon="icon: cart"></span> Add to cart
    </button>

     

    I probably don’t get your message, but as an experienced developer you should get the benefit.

    • Like 1
    • Thanks 1
  8. @Ben Sayers:

    Hey Ben,

    that's what I meant - simply including _uikit.php won't do the job. The whole templates are built using UIKit CSS framework.

    You'll need to write your own templates for product overview and product-details. If you have a look at the two sample templates which are installed by SnipWire installer, you will see how it works. Please have a look at the comments in the php files.

    I currently don't have the time to write sample code based on your rendering method. But if you are familiar with ProcessWire development this should be an easy job.

    Having a look at the snipcart-shop template, all in all, that's all you need:
    (please note this is a quick composition of the required code and might not fully work. And you need to use your own CSS classes based on your framework)

    <!--
    The content element holds your products catalogue.
    -->
    <div id="content">
        <?php
        $products = page()->children('limit=9');
        echo productOverview($products); 
        ?>
    </div>
    
    <?php
    /**
     * Render a shop product overview
     *
     * @param PageArray $products
     * @return string
     *
     */
    function productOverview(PageArray $products) {
    
        if (!$products->count) return '';
        
        $out = '<div class="product>';
    
        foreach ($products as $product) {
            
            // We use the first image in snipcart_item_image field for demo
            $imageMedia = '';
            if ($image = $product->snipcart_item_image->first()) {
                $productImageMedium = $image->size(600, 0, array('quality' => 70));
                $imageDesc = $productImageMedium->description ? $productImageMedium->description : $product->title;
                $imageMedia = '<img src="' . $productImageMedium->url . '" alt="' . $imageDesc . '">';
            } else {
                $imageMedia = 
                '<div title="' . __('No product image available') . '">' . 
                    ukIcon('image', array('ratio' => 3)) . // you need to use your own image output function here because ukIcon is based on UIKit CSS
                '</div>';
            }
            
            // This is the part where we render the Snipcart anchor (buy button)
            // with all data-item-* attributes required by Snipcart.
            // The anchor method is provided by MarkupSnipWire module and can be called 
            // via custom API variable: $snipwire->anchor()
            $options = array(
                'label' => ukIcon('cart'), // use your own image output function
                'class' => 'button button-primary',
                'attr' => array('aria-label' => __('Add item to cart')),
            );
            $anchor = wire('snipwire')->anchor($product, $options);
            
            // Get the formatted product price.
            // The getProductPriceFormatted method is provided by MarkupSnipWire module and can be called 
            // via custom API variable: $snipwire->getProductPriceFormatted()
            $priceFormatted = wire('snipwire')->getProductPriceFormatted($product);
    
            $out .=
            '<a href="' . $product->url . '">' .
                '<div class="product-detail">' .
                    '<div class="media-top">' .
                        $imageMedia .
                    '</div>' .
                    '<div class="card-body">' .
                        '<h3 class="card-title">' . $product->title . '</h3>' .
                        '<p>' . $product->snipcart_item_description . '</p>' .
                    '</div>' .
                    '<div class="card-footer">' .
                        $anchor .
                        '<span class="align-right text-primary">' . $priceFormatted . '</span>' .
                    '</div>' .
                '</div>' .
            '</a>';
        }
    
        $out .= '</div>';
    
        return $out;
    }
    ?>

     

    • Like 1
  9. 30 minutes ago, Ben Sayers said:

    I'm using the Beginner profile, any chance I could convince one of you coding wizards to show me some example code for snipcart-product.php, snipcart-shop.php, and snipcart-cart.php? I'm definitely not a PHP expert but I'm feeling more and more comfortable in PW every day... I'd really like to get this working but my entire site is already built using the Beginner profile and is currently public, I can't rebuild it using the markup regions output strategy. I have my Snipcart account created, the API test is validated but I have the same issue as reported above by @fruid:

    Call to undefined function ProcessWire\ukIcon()

    Note: this project is for a non-profit association and I'm currently donating my time but I would 100% not mind paying someone for their help, feel free to PM me if that's preferred ? 

    You'll need to have a look at the snipcart-shop and snip cart-product templates and modify them so they use the preferred rendering method.

  10. 19 minutes ago, Jozsef said:

    @Gadgetto or anyone else who uses Snipcart to build stores for their clients: How do you justify the extra cost (minimum monthly fee / transaction fee) to clients over free solutions such as Padloper? I'd love to use Snipcart with your integration but given the choice clients go with a free to run system.

    Sorry this is not a technical question but thought you regularly work with Snipcart if you took the time and effort to develop such a deep integration.

    Hi @Jozsef Snipcart is definitely not for everyone. We use it for customers who need to launch their store very fast and don't have a lot of products.

    Are you sure that other free/open source solutions are really free? We have developed some e-commerces sites in the past and the cost of setup and integration of those open source shop systems are very high. And 3 out of 5 shop systems we tested had huge problems when it comes to rounding. Fixing these things cost $$$.

    This quickly puts the cost of the Snipcart system into perspective.

    Snipcart is a very stable system and you don't have to bother with those things as it simply works.

  11. On 12/18/2020 at 11:11 AM, michelangelo said:

    Hello everyone,
    I was curious to know if there is a way to access discounts from SnipWire? I would need it to recalculate the price on the front-end based on the quantity of items.

    This is not yet supported by SnipWire directly. I first need to create a special field type which offers alternate price list creation. This feature is already on my todo list!

    • Like 1
  12. 1 hour ago, michelangelo said:

    Hello everybody,
    anybody had any problem with credit cards not showing up on check out?

    Everything was working fine and I am at the end of the project. But when launched into Live with set up credit card on the seller's side and Paypal, the shopping cart directly sends me to the PayPal. I cannot choose any credit card option. On the back-end of Snipwire I see the three default options Visa, MasterCard, Maestro, but nothing shows up...

    Any ideas? Thank you!

    p.s. @Gadgetto sorry for spamming, I thought I can delete my previous post, but I couldn't maybe somebody else can

    Sorry, I don't know why it's not working for you. I can't reproduce this problem. I tried it in 2 different installations and it works like expected. As I understand, it works in Test environment and when you switch to Live in Snipcart it doesn't!?

    Did you check all settings on Snipcart side? Which payment gateway did you configure in Snipcart?

×
×
  • Create New...