Posts by hus_hmd

    Hello,


    Not sure whether the indexing mechanism is going to change in v4, but if it remains the same, it may be a good idea to have the no-index attribute supported by default. This would give developers greater control on what gets indexed when building sites using add-ons


    e.g. Perch Shop seems to index all product fields including custom fields and the no-index attribute has no effect.

    Yes, you can do this with page attributes and a little bit of PHP: https://grabapipit.com/blog/drafting-at-the-page-level


    If you prefer to write less PHP you can install the Pipit app and use the pipit_perch_user_logged_in() function:


    PHP
    1. // get the page status
    2. $page_status = perch_page_attribute('status', [], true);
    3. if($page_status == 'draft' && !pipit_perch_user_logged_in()) {
    4. // page is draft and user is not logged into Perch control panel
    5. }


    If you are using Runway, you can use your 404 page like so:


    PHP
    1. if($page_status == 'draft' && !pipit_perch_user_logged_in()) {
    2. PerchSystem::use_error_page(404);
    3. exit;
    4. }


    I don't think you can use PerchSystem::use_error_page() on standard Perch. You can redirect to the 404 if you're ok with that. This doesn't respond with a 404 code though.


    PHP
    1. if($page_status == 'draft' && !pipit_perch_user_logged_in()) {
    2. PerchSystem::redirect('/404.php');
    3. }



    Or you can use PHP's http_response_code() to set the HTTP response code and then output you not found message:

    PHP
    1. if($page_status == 'draft' && !pipit_perch_user_logged_in()) {
    2. http_response_code(404);
    3. // display your not found message from a Perch Layout
    4. perch_layout('404');
    5. exit;
    6. }

    Hi James,




    Product customisation

    If the flavours do not affect the pricing, product customisation could be a good solution for this so you can customise each pack. Unfortunately this feature is not yet available in Shop.



    Product options/variants

    I don't think product options/variants would be a suitable for this (assuming the product itself is a package). If you add an Option for flavours and add all the flavours as the Option values, the customer can only select one flavour for the whole package.

    I think you would need to add 12 Options (to match the 12 slots) and add the same flavours as values for all the Options. This would work and allow the customer to select 12 flavours per package, but it may not be great to manage in the back-end.


    Cart properties

    Another option would be to add the flavours as cart properties, but this may be tricky to implement; the customer may order more than one package, but the cart properties are applied to the order and not per product.



    Cupcake as the product?

    You can have the cupcake as the product (and flavours as an Option). The front-end can present this as a package and ask the customer to add a flavoured cupcake per slot in the package. This may also be tricky to implement to account for customers ordering multiple packages.

    Hi,


    I fail to see how this would be helpful to the editor. When an editor adds a new block, I think it makes sense to display the fields to them right away.


    And blocks are already collapsible. You cannot set them to be collapsed by default though.

    Hi,


    How can I specify different buttons and formatting, etc according to the size value I add to the textarea in the template?


    You would use the editor-config attribute for this.


    HTML
    1. <perch:content id="text" type="textarea" label="Text" editor="redactor" editor-config="minimal" html>


    You can access the value of the editor-config attribute in your custom configuration file:


    JavaScript
    1. var get = function(profile, config, field) {
    2. if(profile == 'minimal') {
    3. // hide some buttons
    4. config.buttonsHide = ['link', 'bold'];
    5. }
    6. return config;
    7. };

    Hi Daniel,


    Is there anything specific you would like to know about Perch in order to be able to compare the two products better?


    You can watch the video tutorials which could give you a better idea on what it's like to develop a site with Perch.

    The format you need for filtering does not have to match the date format in the template. It needs to match the format in the database.


    Does the following format work for filtering?


    PHP
    1. $today = date('Y-m-d');

    You don't need to have the filtering logic in PHP and the template. That is, you don't need the conditional tag perch:if if you are filtering with perch_content_custom().


    Also, your $today variable shouldn't have quotes around the date() function. It is also not in the correct format. Try:


    PHP
    1. $today = date('Y-m-d');

    Hello,


    perch_shop_checkout() handles failed payments too.


    I think the ideal approach would be to write a Perch app that listens to the event Perch Shop fires when an order was successfully paid for. You can learn more about event hooks in the documentation.


    Another option would be to use perch_shop_order_successful() to check for a successful order (in your successful payment page for example).


    PHP
    1. if (perch_shop_order_successful()) {
    2. // you have a successful order
    3. }


    Though I think this may evaluate to true for the duration of the user's session. So if the user refreshes the successful payment page, you may be posting duplicate purchases to your marketing/analytics tool.

    Hi,


    I don't think you can filter on blocks. This is not what blocks are for anyway. Fields that essentially define an item (e.g. event date, event title, event slug, categories) shouldn't really be in blocks.


    Try moving the date field outside of your <perch:blocks></perch:blocks>.

    That sounds like a sensible approach. A more powerful perch:if tag would be appreciated regardless.


    I understand not wanting to add this to the app even though I see this as a common use case (any shop that has products with finite stock?).


    It's achievable as is anyway. I wrote a small helper app with a function I can use where necessary: