Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Wordpress plugin and shortcode

 
Reply
   X-Cart forums > Forum archive > Using X-Cart in my project > Need advice
 
Thread Tools
  #1  
Old 07-12-2009, 03:38 AM
  amy2203's Avatar 
amy2203 amy2203 is offline
 

X-Wizard
  
Join Date: Jul 2004
Location: Watford, UK
Posts: 1,506
 

Default Wordpress plugin and shortcode

hoping to be able to create a wordpress plugin and shortcode to easily add product details to posts, things like a thumbnail, title, price, add to cart button.

anyone else interested in anything like this?
__________________
X-Cart version 5 (Previously 3.5-4)

Previous Versions included
BCSE Reward Points Mod
Altered Cart On Sale Mod
Wordpress Plugin

Please don't PM me for support. I help where I can on the forum and your question will more likely be answered there.

Shout me a Coffee!
Reply With Quote

The following user thanks amy2203 for this useful post:
rofea (07-16-2009)
  #2  
Old 07-12-2009, 11:02 PM
 
anandat anandat is offline
 

X-Adept
  
Join Date: Jan 2004
Posts: 913
 

Default Re: Wordpress plugin and shortcode

Hi Amy2203,
yes, this would be very useful plugin.
I am interested in this mod...plz keep me update.
Just make sure that this mod should compitable even if wordpress is on different database than x-cart.
Thanks
__________________
X-Cart: 4.7.7 LIVE
Skin:Ultra by xcartmods.co.uk
X-cart Modules: | ACR, Rich Google Search, Customer Testimonials | Cloud Search, | Websitecm: CDSEO (2.1.9)
---------------
Server: Linux
php: 5.3
mysql: 5.0.89
----------------
Reply With Quote
  #3  
Old 07-13-2009, 02:13 PM
  WebGuyJD's Avatar 
WebGuyJD WebGuyJD is offline
 

Member
  
Join Date: Jun 2009
Posts: 15
 

Default Re: Wordpress plugin and shortcode

Yes! Definitely. Please keep me posted as well. Great Idea.
__________________
X-Cart Gold 4.2.2, Linux
Three Members with Tiered Pricing
X-Affiliate
Smart Menu
Tabbed Menu

------------------------------------
D'Arcy Design and Production
eCommerce and CMS configuration and customization
Reply With Quote
  #4  
Old 07-16-2009, 04:32 AM
  amy2203's Avatar 
amy2203 amy2203 is offline
 

X-Wizard
  
Join Date: Jul 2004
Location: Watford, UK
Posts: 1,506
 

Default Re: Wordpress plugin and shortcode

it looks like its working at a basic level, i've not put in an admin panel yet for the settings so they are all in the single php file.

not sure if I'll get round to doing anything else on this soon as it works for me, so thought I'd put it here in case anyone else wants it,

save the following as xcart.php and save in your wp-plugins folder. There are a number of places where you will need to insert your settings, marked with ****, and it's designed for wordpress to be on a different database than xcart,

Code:
<?php /* Plugin Name: Xcart Links Plugin URI: http://www.willowtreecrafts.co.uk Description: Insert your Xcart products into your posts Version: 0.1 BETA Author: Amy Gibbs Author URI: http://www.willowtreecrafts.co.uk */ /* Xcart Links (Wordpress Plugin) Copyright (C) 2009 Amy Gibbs Contact me at http://www.willowtreecrafts.co.uk This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ //tell wordpress to register the xcart shortcode add_shortcode("xcart", "xcart_product_handler"); function xcart_product_handler($attr) { extract(shortcode_atts(array( 'product' => 'none', ), $attr)); //$product=m111100; //connect to xcart db $dbc=@mysql_connect ('****','****','****'); $dbc=@mysql_select_db('****'); //query the xcart db $q = "SELECT * FROM xcart_products LEFT JOIN xcart_pricing USING(productid) LEFT JOIN xcart_images_T ON productid=id WHERE productcode='".$product."'"; //echo $q; $results = mysql_query($q); $productdata = mysql_fetch_assoc($results); $xcart_output= "<form name='orderform_".$productdata[productid]."' method='post' action='http://www.willowtreecrafts.co.uk/shop/cart.php'>"; $xcart_output= $xcart_output."<input type='hidden' name='mode' value='add' /><input type='hidden' name='amount' value='1'>"; $xcart_output= $xcart_output."<input type='hidden' name='productid' value='".$productdata[productid]."' />"; $xcart_output= $xcart_output."<div><div>".$productdata[product]."</div><div><img id='product_thumbnail' src='http://www.willowtreecrafts.co.uk/shop/imager.php/product_thumb.jpg?width=500&image=http://www.willowtreecrafts.co.uk/shop/images/T/".$productdata[filename]."' width='100' style='margin:5px;' alt='".$productdata[product]."' /></div>"; $xcart_output= $xcart_output."<div class='ProductPriceConverting' valign='top'>Price: <font class='ProductDetailsTitle'><span style='WHITE-SPACE: nowrap'>&pound;".$productdata[price]."</span></font><font class='MarketPrice'> </font></div>"; $xcart_output= $xcart_output."<div><a class='Button' href='javascript: document.orderform_".$productdata[productid].".submit();'>Add to cart </a></div> </div> </form>"; //send back text to replace shortcode in post return $xcart_output; } ?>

then in your posts use the shortcode like the following. where 76027 is the SKU of the product.

[xcart product="76027"]

you might want to add some css to pretty it up, there are some calsses etc in there,

hope it's useful, if anyone wants to develop it further feel free,
__________________
X-Cart version 5 (Previously 3.5-4)

Previous Versions included
BCSE Reward Points Mod
Altered Cart On Sale Mod
Wordpress Plugin

Please don't PM me for support. I help where I can on the forum and your question will more likely be answered there.

Shout me a Coffee!
Reply With Quote
  #5  
Old 07-16-2009, 06:59 AM
 
anandat anandat is offline
 

X-Adept
  
Join Date: Jan 2004
Posts: 913
 

Default Re: Wordpress plugin and shortcode

hi amy2003,
I tried to play with the code at localhost & I got the following error
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in D:\xampp\htdocs\blog\wp-content\plugins\xcart.php on line 57

I have replaced all your web site links with my site links & changed the database setting also.
I guess in following line of the code there is no file "imager.php" is my x-cart root directory.

$xcart_output= $xcart_output."<div><div>".$productdata[product]."</div><div><img id='product_thumbnail' src='http://www.willowtreecrafts.co.uk/shop/imager.php/product_thumb.jpg?width=500&image=http://www.willowtreecrafts.co.uk/shop/images/T/".$productdata[filename]."' width='100' style='margin:5px;' alt='".$productdata[product]."' /></div>";

Please help to resolve the issue
__________________
X-Cart: 4.7.7 LIVE
Skin:Ultra by xcartmods.co.uk
X-cart Modules: | ACR, Rich Google Search, Customer Testimonials | Cloud Search, | Websitecm: CDSEO (2.1.9)
---------------
Server: Linux
php: 5.3
mysql: 5.0.89
----------------
Reply With Quote
  #6  
Old 07-16-2009, 07:55 AM
  amy2203's Avatar 
amy2203 amy2203 is offline
 

X-Wizard
  
Join Date: Jul 2004
Location: Watford, UK
Posts: 1,506
 

Default Re: Wordpress plugin and shortcode

Quote:
Originally Posted by anandat
hi amy2003,

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in D:\xampp\htdocs\blog\wp-content\plugins\xcart.php on line 57

Please help to resolve the issue

the problem is that the mysql query is not returning a product, are you using the SKU in the shortcode?
__________________
X-Cart version 5 (Previously 3.5-4)

Previous Versions included
BCSE Reward Points Mod
Altered Cart On Sale Mod
Wordpress Plugin

Please don't PM me for support. I help where I can on the forum and your question will more likely be answered there.

Shout me a Coffee!
Reply With Quote
  #7  
Old 07-17-2009, 05:48 AM
 
anandat anandat is offline
 

X-Adept
  
Join Date: Jan 2004
Posts: 913
 

Default Re: Wordpress plugin and shortcode

Quote:
Originally Posted by amy2203
the problem is that the mysql query is not returning a product, are you using the SKU in the shortcode?
Yes I have used SKU in short code. also my product id & SKU are same.
For example for product id & SKU number for product 3415 I put [xcart product="3415"]

r u sure there is file "imager.php" in x-cart root ?
__________________
X-Cart: 4.7.7 LIVE
Skin:Ultra by xcartmods.co.uk
X-cart Modules: | ACR, Rich Google Search, Customer Testimonials | Cloud Search, | Websitecm: CDSEO (2.1.9)
---------------
Server: Linux
php: 5.3
mysql: 5.0.89
----------------
Reply With Quote
  #8  
Old 07-17-2009, 06:02 AM
  amy2203's Avatar 
amy2203 amy2203 is offline
 

X-Wizard
  
Join Date: Jul 2004
Location: Watford, UK
Posts: 1,506
 

Default Re: Wordpress plugin and shortcode

try running this query on your database directly and see if it works

SELECT * FROM xcart_products LEFT JOIN xcart_pricing USING(productid) LEFT JOIN xcart_images_T ON productid=id WHERE productcode=3415
__________________
X-Cart version 5 (Previously 3.5-4)

Previous Versions included
BCSE Reward Points Mod
Altered Cart On Sale Mod
Wordpress Plugin

Please don't PM me for support. I help where I can on the forum and your question will more likely be answered there.

Shout me a Coffee!
Reply With Quote
  #9  
Old 07-17-2009, 06:03 AM
  amy2203's Avatar 
amy2203 amy2203 is offline
 

X-Wizard
  
Join Date: Jul 2004
Location: Watford, UK
Posts: 1,506
 

Default Re: Wordpress plugin and shortcode

Quote:
Originally Posted by anandat
r u sure there is file "imager.php" in x-cart root ?

Am I sure that YOU have a file called imager.php in your root? funnily enough no! have a look at your file manager to see if it's there
__________________
X-Cart version 5 (Previously 3.5-4)

Previous Versions included
BCSE Reward Points Mod
Altered Cart On Sale Mod
Wordpress Plugin

Please don't PM me for support. I help where I can on the forum and your question will more likely be answered there.

Shout me a Coffee!
Reply With Quote
  #10  
Old 07-17-2009, 06:35 AM
 
anandat anandat is offline
 

X-Adept
  
Join Date: Jan 2004
Posts: 913
 

Default Re: Wordpress plugin and shortcode

Quote:
Originally Posted by amy2203
try running this query on your database directly and see if it works

SELECT * FROM xcart_products LEFT JOIN xcart_pricing USING(productid) LEFT JOIN xcart_images_T ON productid=id WHERE productcode=3415
Yes, query is running fine in phpmyadmin
__________________
X-Cart: 4.7.7 LIVE
Skin:Ultra by xcartmods.co.uk
X-cart Modules: | ACR, Rich Google Search, Customer Testimonials | Cloud Search, | Websitecm: CDSEO (2.1.9)
---------------
Server: Linux
php: 5.3
mysql: 5.0.89
----------------
Reply With Quote
Reply
   X-Cart forums > Forum archive > Using X-Cart in my project > Need advice


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 01:37 AM.

   

 
X-Cart forums © 2001-2020