Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WooCommerce support #1923

Closed
wants to merge 1 commit into from
Closed

WooCommerce support #1923

wants to merge 1 commit into from

Conversation

QWp6t
Copy link
Member

@QWp6t QWp6t commented Jul 9, 2017

I'm personally against adding this to Sage out of the box. I think it would be better to put it on our docs, and that's probably what will wind up happening, but I figured I would go ahead and submit a PR anyway for now if for no other reason than to serve as an interim example for using Blade with third-party plugins.

@christianmagill
Copy link

Maybe a composer option?

@QWp6t QWp6t closed this Jul 24, 2017
@QWp6t QWp6t deleted the woocommerce-support branch July 24, 2017 20:03
@arthurkirkosa
Copy link

I keep running into Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function startSection() on null in ... cache ... line 1 with this approach

This is the content of that file.

<?php $__env->startSection('content'); ?>
  <?php while(have_posts()): ?> <?php (the_post()); ?>
    <?php echo $__env->make('partials.page-header', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
    <?php echo $__env->make('partials.content-page', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
  <?php endwhile; ?>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

I've created resources/views/woocommerce/content-product.blade.php that has the content from page.blade.php

@eljass
Copy link

eljass commented Aug 23, 2017

I keep running into Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function startSection() on null in ... cache ... line 1 with this approach

Did you @arthurkirkosa find any solutions for this? I'm getting the same error.

@arthurkirkosa
Copy link

// resources/views/woocommerce.blade.php
@extends ('layouts.app')

@section ('content')
@php (woocommerce_content())
@stop
// resources/views/woocommerce/archive-product.php
<?php echo App\Template('woocommerce');

In a partial I have

<div class="row mb-5">
    @while ($products->have_posts()) @php ($products->the_post())
    <div class="col-sm-4">
        <div class="product product-border">
            <a class="woocommerce-loop-product__link" href="{{ get_permalink() }}">
                {!! woocommerce_get_product_thumbnail() !!}
                <div class="woocommerce-loop-product__title">{{ the_title() }}</div>
            </a>

            {!! woocommerce_template_loop_price() !!}
        </div>
    </div>
    @endwhile
</div>
<?php

namespace App\Traits;

use WP_Query;

trait Products
{
    public function products()
    {
        return new WP_Query([
            'post_type' => 'product',
            'posts_per_page' => 3,
            'tax_query' => [
                [
                    'taxonomy' => 'product_visibility',
                    'field' => 'name',
                    'terms' => 'featured',
                ],
            ],
        ]);
    }
}

Not exactly what I wanted... but it's the best I got so far... would have liked to be able to override the actual HTML structure, but... ¯_(ツ)_/¯

Maybe someone can help us with that part.

I was able in Sage 8 to do it... but not sure how to in Sage 9 (and I'm a Laravel developer :D)

@nboliver
Copy link

nboliver commented Nov 6, 2017

@QWp6t The pr you posted was really helpful. Is it possible to use blade templates instead of php templates though?

@QWp6t QWp6t mentioned this pull request Jul 17, 2018
@QWp6t QWp6t mentioned this pull request Jul 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants