Jump to content

Woocommerce Plugin Integration Problem


jsmith1981

Recommended Posts

Having problems integrating woocommerce.

 

I am working on showing just a list of products to begin with, I mean taking the contents of 'archive-product.php' from the templates directory in the woocommerce plugin folder (don't need to explain where that is).

 

I have got the following:

<?php
/*
Template Name: Homepage
*/

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

// get_header(); // this is now deactivated!
get_header('shop');
/**
* woocommerce_before_main_content hook
*
* @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
* @hooked woocommerce_breadcrumb - 20
*/
do_action('woocommerce_before_main_content');
?>

<?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?>

		<h1 class="page-title"><?php woocommerce_page_title(); ?></h1><!-- page heading basically -->

<?php endif; ?>
<?php // do_action( 'woocommerce_archive_description' ); // keep this disabled for now ?>

<div id="products-banner">

	<?php if ( have_posts() ) : ?>

		<?php
			/**
			 * woocommerce_before_shop_loop hook
			 *
			 * @hooked woocommerce_result_count - 20
			 * @hooked woocommerce_catalog_ordering - 30
			 */
			do_action( 'woocommerce_before_shop_loop' );
		?>

		<?php woocommerce_product_loop_start(); ?>

			<?php woocommerce_product_subcategories(); ?>

			<?php while ( have_posts() ) : the_post(); ?>

				<?php woocommerce_get_template_part( 'content', 'product' ); ?>

			<?php endwhile; // end of the loop. ?>

		<?php woocommerce_product_loop_end(); ?>

		<?php
			/**
			 * woocommerce_after_shop_loop hook
			 *
			 * @hooked woocommerce_pagination - 10
			 */
			do_action( 'woocommerce_after_shop_loop' );
		?>

</div>

<div class="footer">
 <ul>
   <li>Link 1</li>
 </ul>
</div>

<?php get_footer(); ?>

 

It's then coming up with (when I refresh my browser) with the following:

'Parse error: syntax error, unexpected end of file' then shows the file I am editing which is basically home.php (my wordpress template file) on the last line, I really am confused by this.

 

Is there anything I am doing that's completely wrong here? I mean i went through judging by the logic I would have thought this should work?

 

Any help's massively appreciated,

Jeremy

 

PS Sorry to edit this but I shortened it to this:

<?php
/*
Template Name: Homepage
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
// get_header(); // this is now deactivated!
get_header('shop');
do_action('woocommerce_before_main_content');
?>

<?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?>

		<h1 class="page-title"><?php woocommerce_page_title(); ?></h1><!-- page heading basically -->

<?php endif; ?>
<?php // do_action( 'woocommerce_archive_description' ); // keep this disabled for now ?>

<div id="products-banner">

	<?php if ( have_posts() ) : ?>

		<?php
			do_action( 'woocommerce_before_shop_loop' );
		?>

		<?php woocommerce_product_loop_start(); ?>

			<?php woocommerce_product_subcategories(); ?>

			<?php while ( have_posts() ) : the_post(); ?>

				<?php woocommerce_get_template_part( 'content', 'product' ); ?>

			<?php endwhile; // end of the loop. ?>

		<?php woocommerce_product_loop_end(); ?>

		<?php
			do_action( 'woocommerce_after_shop_loop' );
		?>

</div>

<div class="footer">
 <ul>
   <li>Link 1</li>
 </ul>
</div>

<?php get_footer(); ?>

 

Just basically because I know what everything is, most of what wp wants has to be in the top part of the file (source) have I missed something off like an actual product file or something perhaps? I am really just clueless as to what's going wrong.

Edited by Jeremy
Link to comment
Share on other sites

Ok sorry I fixed the end of file problem, using this logic:

 

<?php
/*
Template Name: Homepage
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
// get_header(); // this is now deactivated!
get_header('shop');
do_action('woocommerce_before_main_content');
?>

<?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?>

		<h1 class="page-title"><?php woocommerce_page_title(); ?></h1><!-- page heading basically -->

<?php endif; ?>
<?php // do_action( 'woocommerce_archive_description' ); // keep this disabled for now ?>

<div id="products-banner">
<?php if ( have_posts() ) : ?>



		<?php
			do_action( 'woocommerce_before_shop_loop' );
		?>

		<?php woocommerce_product_loop_start(); ?>

			<?php woocommerce_product_subcategories(); ?>

			<?php while ( have_posts() ) : the_post(); ?>

				<?php woocommerce_get_template_part( 'content', 'product' ); ?>

			<?php endwhile; // end of the loop. ?>

		<?php woocommerce_product_loop_end(); ?>

		<?php
			do_action( 'woocommerce_after_shop_loop' );
		?>

     <?php elseif ( ! woocommerce_product_subcategories( array( 'before' => woocommerce_product_loop_start( false ), 'after' => woocommerce_product_loop_end( false ) ) ) ) : ?>

     <?php woocommerce_get_template( 'loop/no-products-found.php' ); ?>
<?php endif; ?>
<?php do_action('woocommerce_after_main_content'); ?>
</div>

<div class="footer">
 <ul>
   <li>Link 1</li>
 </ul>
</div>

<?php get_footer(); ?>

 

I have a random generated test product with whatever details (not that any of them should stop it from showing), but I put the above code in say home.php

 

But literally nothing shows up, I will rerun through my settings but does anyone have a clue if it's the logic above that's stopping them from showing? (or it rather depending on if you've got one or whatever number of products lol).

 

Doing really well with my logical assumptions though, actually this is a heck of allot easier than I first thought, just this is getting in the way. Interesting though.

 

Look forward hearing anyone's help,

Jeremy.

Link to comment
Share on other sites

Oh no probs Andrea, I think I have this understood now, I think it's just the V part of MVC that's causing the problem.

 

I thought why not just look into where you go when you look at the site, like home and whatever (index.php) is the kind of page it goes to (gets a bit confusing at times) but if I set it to go to the home page I have made in my logic I think it'll be fine.

 

Because when I go to look at any of the products and using the breadcrumb plugin it goes back to the GET part of the address and finds the root category for products and displays them all, I might just put in some statically done previews (like the previous showsite I showed you and you very kindly offered some advice on).

 

Thanks ever so much for your reply, though if anyone else who knows more about php wants to advise me on this that'd be wonderful :)

 

Take care Andrea,

Jeremy.

 

(as an edit to this post, least my theme's robust haha, tried it on a test sandbox I have a real fully working hardware VPS server and that works, it's like I wanted to kind of jump up and down and go yea lol, very sad behaviour haha :D)

Edited by Jeremy
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...