Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Steve Pfisterer
    @stevep
    its nice because it can embed them so you can use css to stlye their contents
    Marko Bolliger
    @cannap
    and i like svg symbols
    because no whitespace like fonts
    Steve Pfisterer
    @stevep
    do you use composer with your wordpress installs?
    Marko Bolliger
    @cannap
    yea always but most times i dont need
    Steve Pfisterer
    @stevep
    do you just use it plain or do you use sage/roots or something?
    errr bedrock i think i mean
    Marko Bolliger
    @cannap
    but i will create my own boilerplate
    for my next projects this one sucks a bit
    not sure i will stay on twig sage/roots has blade support from laravel
    but woocommerce support is not 100% i think
    Steve Pfisterer
    @stevep
    you prefer blade to twig?
    Marko Bolliger
    @cannap
    its simpler
    but atm i like twig
    i know blade from laravel
    i dont know what changed with the time
    best would be vuejs :D
    Steve Pfisterer
    @stevep
    i’ve not used. to me its like handlebars (twig) vs haml (blade) but ive not looked into it really
    Marko Bolliger
    @cannap
    but php cant handle ssr with vuejs
    nunjuck is more like twig
    from mozzila
    i do much js then i need to rethink so much stuff
    but blade i know
    @ stuff is nice
    sry my english is not so good
    maybe i write something wrong xD
    Steve Pfisterer
    @stevep
    ya sometimes its hard to transition between langauges / environments
    (programming languages)
    big context switch
    Marko Bolliger
    @cannap
    yea i use js without ";"
    and then i write php forgot everytime to terminate
    the line
    Steve Pfisterer
    @stevep
    ive changed over to phpstorm full time and it will yell at me, good for catching bugs
    Marko Bolliger
    @cannap
    are you using xdebug?
    Steve Pfisterer
    @stevep
    Sometimes, it can be very useful
    Lara Schenck
    @laras126
    Hey all! Question: what is the purpose of header.php and footer.php in a Timber theme? It looks to me like they just add output buffering, but is that used at all in Timber itself, Or just there for plugins/whatever?
    Jared Novack
    @jarednova
    @laras126 it's for some plugins like Events Calendar Pro and WooCommerce that need explicit header/footer.php files for whatever reason
    Ricky Green
    @rgcouk
    Hello all. :)
    Looking for a little bit of direction, i would like to display woocommerce cart view in the header, basic icon, total and number or items, i've been search google but i can't find anything relevant.
    Ricky Green
    @rgcouk
    Anyone around?
    Ricky Green
    @rgcouk
    Morning.
    Lukas Gächter
    @gchtr
    @rgcouk Hi Ricky. No worries, people read this channel and if they have an answer, they’re happy to help. Questions about WooCommerce and Timber come in from time to time (https://gitter.im/timber/timber?at=587fc42711e7a7f61db2db24). But solutions for integrating WooCommerce with Timber are sparse, I guess.
    Ricky Green
    @rgcouk
    Hello Lukas, Thanks for your input, ill check that link out.
    Ricky Green
    @rgcouk
    Hmm, Okay, I basically want the cart view in the header without a plugin.
    Ricky Green
    @rgcouk
    @gchtr You still around please?
    Lukas Gächter
    @gchtr
    @rgcouk I’m afraid I can’t help you with WooCommerce, because I don’t use it.
    Ricky Green
    @rgcouk

    Yes, thats fine, but you maybe able to shed some light on something for me?

    I've copied over mini-cart.php and importing it to my twig file but it display the PHP code, I'm guessing i've got to covert it to twig and call it like i do the other pages? $context['cart'] = WC()->cart->get_cart();, i just need to know if theres a standard, not going to say easy way because i know that rarely exists

    Lukas Gächter
    @gchtr

    @rgcouk The starting point for working with WooCommerce seems to be http://timber.github.io/timber/#woocommerce. That’s probably the only standard that exists.

    When using Timber, you don’t necessarily have to convert everything to Twig. You could still use PHP. If you need the output of a PHP file in a Twig file, something like this might work:

    ob_start();
    include ('path/to/mini-cart.php');
    
    $context['minicart'] = ob_get_contents();
    ob_end_clean();

    As you assumed, importing PHP code directly into Twig won’t work, so you’d have to convert it to Twig. Something like this might work:

    $context['cart'] = WC()->cart;

    In your Twig file you could maybe do something like this:

    
    {% if not cart.is_empty }
        {% do action( 'woocommerce_before_mini_cart_contents' ) %}
    
        {% for cart_item_key, cart_item in cart.get_cart %}
            {% set product = fn('apply_filters', 'woocommerce_cart_item_product', cart_item.data, cart_item, cart_item_key)}
    
            {# … #}
        {% endfor %}
    {% endif %}