Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1043762

    Hi everebody,
    Using WordPress 5 + Woocommerce 3.5.2 + WPML + Grimp (deprecated but essential and lightweight PHP injection plugin), testing on a stage site
    Here is the simple case: I need to have products displayed in a product slider if, and only if, the number of products of a specific category is not null.
    This can easily be done with some PHP code:

    <?php
    $id_cat = 931; /*931 product category code aimed*/
    $p_cat = get_term_by( id, $id_cat, product_cat); /*getting the product category datas */
    $s_c = "[av_productslider cats='".$id_cat."' items='".$p_cat->count."' columns='4' autoplay='yes' interval='8' sort='date' av_uid='av-1vdt00']"; /*implementing the product slider*/
    $err = '<span class="cat_vide">Sorry, no special offer now.</span>'; /*alternate display if no product found*/
    echo ( $p_cat->count> 0 ) ? do_shortcode($s_c) : $err;
    ?>

    From this point a few comments are to be given:
    1/ I do know that with WordPress 5, script functions should be implemented in my theme or child theme functions.php for excellent security reasons. Yep ! But it’s a true pain in the ass. The faintest coding error and the entire web is broken! Moreover, the entire hooks and filter manual has to be learnt by heart if I want to use my script function in the proper way while injecting code in a page is simple as “bonjour”
    2/ welcome to the undefined and undescribed world when using avia shortcodes. Oh yes!, I know that they are listed here: https://kriesi.at/support/topic/content-slider-example/ and there: https://kriesi.at/support/topic/custom-shop-end-custom-product-woocommerce-enfold-2017/ But where is the help describing the way to use and implement those shortcodes, what are the parameters ranges, which ones are compulsory and which ones are optional?
    3/ please notice that with avia shortcodes now simple and double quotes uses are inverted, meaning that from now on the parameters values need simple quotes, therefore in my script $s_c i declared with double quotes while $err with simple quotes, Funny!
    Back to my issue. I am now able to display only 4 products, one per column, how do I have the $p_cat->count number of products displayed by 4 columns while sliding with a 8 second pause?
    If someone is courageous enough to write for me the entire code to be placed in my child theme functions.php instead of my script injection that would be Christmas before time!
    Thanks for any kind hlep.
    Kind regards.
    Gilles

    #1047608

    Hey scriptorium,

    1.) Did you add that modification directly in the productslider.php file? You can use this filter to enable shortcodes in your child theme or allow the parent shortcode files to be overridden.

    // https://kriesi.at/documentation/enfold/intro-to-layout-builder/#add-elements-to-alb

    2.) One of the reasons those parameters are not listed because users ought to use the Advance Layout Builder and not tinker with the shortcodes directly. A simple way to know which parameters are required is when they’re not filled in when you insert the shortcode. The docs might help.

    // https://kriesi.at/documentation/enfold/

    3.) I don’t really see any issue with that.

    4.) Are you referring to the slider interval? There is an interval parameter.

    Best regards,
    Ismael

    #1048221

    Hey Ismael,
    1) No I didn’t. I explicitly wrote that I used php code in the page itself as plain text
    2) The doc is useless, the product slider is neither enlisted nor described. Actually I used the ALB to configure the slider itself then switched to the classic editor and so got my shortcode parameters
    No, no issue at all but the following points:
    a/ the online doc is not complete, many shortcodes are missing and the ones described usually show only a few parameters
    b/ it is currently not any more possible to write php code using the classic editor, therefore not possible to evaluate anything before a display (while with Abundance it is!)
    c/ it is only possible to uses plugins which create shortcode with user defined php functions BUT Enfold do not accept cascading calls to shortcode!
    Yes Ismael, you’re right, everything’s fine and Christmas is almost there.
    Best regards.
    Gilles
    By the way, I was said a year and half ago that Abundance wouldn’t be let down. Keep waiting and see nothing but I’m still believing Santa Claus would come for me.

    #1049051

    Hi,

    Where exactly do you want to insert the product slider? You can use the “ava_after_main_container” hook if you want to insert something right after the header container or the “ava_before_footer” hook for those things that have to be inserted before the footer.

    Setting the builder to debug mode might help:

    // https://kriesi.at/documentation/enfold/intro-to-advanced-layout-builder/#debug-mode

    Best regards,
    Ismael

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.