Here’s how I did it.
1. Create a file called curl.php
2. Paste into it the following code (and save it).
Code: Select all
<?php
$ch = curl_init("http://www.opencartinstall.com");
$html = curl_exec($ch);
print $html;
?>
3. Copy your newly created curl.php file to the root of your Wordpress template folder.
4. It may well already be there, but make sure in your Wordpress template header.php file (within the <head></head> section), you’ve got a link to the latest version of jQuery. The following code will do that;
Code: Select all
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
Code: Select all
<script type="text/javascript">
$("document").ready(function() {
$("#pull-featured").load("<?php bloginfo( 'template_url' ); ?>/curl.php #featured");
});
</script>
Code: Select all
<div id="pull-featured"></div>
Code: Select all
<div class="box">
<div class="box-heading"><?php echo $heading_title; ?></div>
Code: Select all
<div class="box" id="featured">
<div class="box-heading"><?php echo $heading_title; ?></div>
basically what’s happening is that the javascript is asking curl.php to ‘load’ the homepage of the shop. Once that’s loaded, it finds within the code of that page the div that we’ve given the ID of ‘featured’ to, and pulls everything within it into the ‘pull-featured’ div in the Wordpress template.
* however *
It just loads and displays the html as is, so you’ll need to style the new #featured div with your Wordpress template’s stylesheet (easily done with css)
More importantly though is that the add to cart buttons won’t work. This is because in Opencart version 1.5 the add to cart buttons in the Featured module rely on javascript to function. The wordpress template doesn’t have that javascript as it lives on the opencart site. Potentially, we could load that javascript into Worpdress, but I ran into problems doing that, so I had to get ‘creative’ ;-) I created another add to cart button that would work outside Opencart, and hid the native Opencart button with css.
so...
1. in Opencart’s catalog/view/theme/yourtheme/template/module/featured.tpl
change:
Code: Select all
<div class="cart"><a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button"><span><?php echo $button_cart; ?></span></a></div>
Code: Select all
<div class="cart oc-addtocart"><a onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button"><span><?php echo $button_cart; ?></span></a></div>
<div class="wp-addtocart">
<form action="http://www.opencartinstall.com/index.php?route=checkout/cart" method="post">
<input type="hidden" name="product_id" value="<?php echo $product['product_id']; ?>" />
<input type="hidden" name="quantity" value="1" />
<input type="submit" name="submit" value="ADD TO CART" class="submit" />
</form></div>
Code: Select all
.oc-addtocart {display:none;}
Code: Select all
.wp-addtocart {display:none;}
Hope this helps
cheers
Matt