Posts by Mxkert

    You have to specify the id of the field you wish to sort by, for example:


    PHP
    1. <?php
    2. perch_blog_custom(array(
    3.     'count' => 3,
    4.     'template' => 'post_homepage.html',
    5.     'sort' => 'title',
    6.     'sort-order' => 'DESC',
    7.     'sort-type' => 'numeric'
    8. ));
    9. ?>

    It worked. I now used the SKU to check if the product already exists, if not I import the product.


    Code
    1. foreach($result['data'] as $productData){
    2. $Products = new PerchShop_Products();
    3. $newProduct = $Products->get_one_by('sku', $productData['productcode']);
    4. if (!$productData['productcode'] == $newProduct) {
    5.                 #
    6.             }
    7.         }

    Hello,


    Is it possible to use the PerchShop_Products to find a product using the slug or any other field, instead of searching for the ID like this example:


    Code
    1. $Products = new PerchShop_Products();
    2. $newProduct = $Products->find($product['id']);

    Can we use the ->find for looking for the slug?

    With <?php perch_content('Rooms Main');?> you are creating a region, which now will show up in the Perch Dashboard. There you can select a template that you will be using to fill the region with.


    So for example in /perch/templates/content/ you can create a file named rooms_main.html. In this file you put the code:

    Code
    1. <perch:content id="body" type="textarea" label="Article body" html editor="redactor">


    Now when selecting a template for the region, this rooms_main.html template will show up and you can use this template to fill the region with.


    My suggestion:

    Instead of your code, I would only write <?php perch_content('Rooms');?> on your page.

    Then for the template (create it in /perch/templates/content/rooms.html) I would use:

    Code
    1. <h1><perch:content id="heading" type="text" label="Heading"></h1>
    2. <perch:content id="body" type="textarea" label="Body" html editor="redactor">

    So now you can write your page from one region instead of two.

    Sometimes, after moving a website, I have to remove the core folder and upload a fresh downloaded core folder to the server for the WYSIWYG to show up.


    EDIT: Make sure to make a back-up first!

    Answer to Q2:


    In the documentation you can find a way to sort blog posts by a field, and choose Descending (DESC), Ascending (ASC) or Random (RAND) sorting:

    https://docs.grabaperch.com/fu…/perch-blog-recent-posts/


    If you would like to alphabetically sort your blog posts by title, for example, you could use:


    PHP
    1. <?php
    2. perch_blog_custom(array(
    3. 'count' => 10,
    4. 'template' => 'post_in_list.html',
    5. 'sort' => 'postTitle',
    6. 'sort-order' => 'DESC',
    7. ));
    8. ?>

    First 10.000 char of debug:


    Here you go:



    I beautified the most important part:



    orderItemsTotal and orderSubtotal do have decimals in place, but are not strings.