Guest Posted May 3, 2003 Posted May 3, 2003 Well, I've searched and haven't found, so I'll ask you all... I sell a number of logo related items through a store on CafePress.com (fyi, an online print-on-demand t-shirt shop), and would like to link from OSC to my store on cafepress.com. Ideally, I would like to have the customer click on the category "Our CafePress Store" and have a new window open containing the cafepress store. Second option would be to have the category take the customer to the category-product page, and then the customer would click on the desired design and again have a new window open containing the cafepress store. The third, and least desirable option is to simply use the manufacturer's product page link on the product page to do this. This, however, is a little messy, since we need to get rid of the price (displayed as $0.00, since the cafepress items are different prices depending on options), and the ADD TO CART button. Possibly with some sort of IF..THEN like "If price=0 then don't show it or the add to cart". Unfortunately, I am not a good enought coder to try any of this on my own, and would be happy to have a little guidance, or perhaps a mod. :oops: Thanks, Phil Quote
loxly Posted May 3, 2003 Posted May 3, 2003 Why bother using osc for a front end if you just want to sell through cafepress directly? There are a number of scripts in the cafepress custom shops forum that will build a store at your own site. I am using osc to present all the products I am also selling through Cafepress, and similar places, but I process the orders through osc and place the orders myself with the vendors, keeping the commission due me upfront. This allows you to present your poducts in a variety of ways, offer products that you have not yet uploaded to Cafepress and gives you the ability to use a different vendor to process your orders if you find cafepress insn't fullfilling your needs. Additionally, cafepress has announced that their linking is not stable and they can change the way they create links to the products and images at any time without prior warning. They do not support custom linking, you do so at your own risk. Three times in the last several months folks with custom stores woke up to find their stores empty or linking to site not found. Things to think about. The other reason I choose osc to feature my products that I am also selling through cafepress is so I could offer an affiliate program, something you can't do with direct links to cafepress shopping cart. Ideally, I would like to have the customer click on the category "Our CafePress Store" and have a new window open containing the cafepress store. This can be accomplished with a simple text link with the target=_blank command in the a href Quote [no external urls in signatures please, kthanks]
Guest Posted May 3, 2003 Posted May 3, 2003 I guess I wasn't clear... I am not *just* selling Cafepress products, otherwise this wouldn't be an issue. I have a number of other items that I keep in stock, and sell the logo items through Cafepress as an added feature. Also, I am using the coolMenu mod, which uses the categories db to build an hierarchical drop down menu, so a simple text link would not work within this mod. I have never had a problem linking to my cafepress store, using their proscribed linking methods, in the two years that I have run my stores. I am not wishing to link to a specific product, only to the store. Basically, I am trying to make it easier for the customer to discover and view my cafepress shops by including them in the categories drop down menu. Thanks, Phil Quote
orchard Posted May 3, 2003 Posted May 3, 2003 You can get what I think you want fairly easily. Create a new category named Our CafePress Store and find out it's cPath value (click it and look in the URL). Then insert lines near the top of default.php as shown here if (isset($cPath) && tep_not_null($cPath)) { // start of hack if ( $cPath == 32 ) // replace 32 with your cPath number { header( 'Location: http://www.oakvalley.com' ); // replace oakvalley.com with your URL exit; } // end of hack $categories_products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . $current_category_id . "'"); I just tried it on my store and it worked fine. Quote In olden times the men were made of iron and the ships were made of wood; now it's the other way around. :wink:
Guest Posted May 3, 2003 Posted May 3, 2003 Thanks! That works great, after a few minor modifications. Since the link I wanted was from a second level menu I had to change the cpath number to '6_7' including the quotes. I also commented out the original portion of the code that you changed. Does this look right? It seems to work... The final result, starting around line 15 is: // the following cPath references come from application_top.php$category_depth = 'top'; /*Comment this portion out for external link hack if ($cPath) { */ // INSERT EXTERNAL LINK HACK HERE if (isset($cPath) && tep_not_null($cPath)) { // start of hack if ( $cPath == '6_7' ) // replace 6_7 with your cPath number { header( 'Location: http://www.cafeshops.com/seafire_camb,seaf...e,seafire_fest' ); // replace with your external URL exit; } // end of hack //END EXTERNAL LINK HACK $categories_products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . $current_category_id . "'"); $cateqories_products = tep_db_fetch_array($categories_products_query); if ($cateqories_products['total'] > 0) { $category_depth = 'products'; // display products } else { $category_parent_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where parent_id = '" . $current_category_id . "'"); $category_parent = tep_db_fetch_array($category_parent_query); if ($category_parent['total'] > 0) { $category_depth = 'nested'; // navigate through the categories } else { $category_depth = 'products'; // category has no products, but display the 'no products' message } } } This should give anyone else a better idea of where to place the code. Only problem is that it doesn't open a new window. :( Any ideas on how to accomplish that? Thanks again, Phil Quote
orchard Posted May 3, 2003 Posted May 3, 2003 I'm glad you got it working. :) The normal way to open a new window would be to find the <a href= for the category and add target="_blank" into the href, but it wasn't obvious to me where to do this in the osCommerce code. There's nice searchable documentation for PHP at www.php.net, but I'm not sure what to search for there. Quote In olden times the men were made of iron and the ships were made of wood; now it's the other way around. :wink:
Guest Posted May 11, 2003 Posted May 11, 2003 Hi all, I too am using the above code to redirect (but also require it in a new window). Can anyone help here? Have tried php.net manual & can't seem to find a solution. Please, please, please. Really need a solution. thanks Rob Quote
grantjm Posted May 15, 2003 Posted May 15, 2003 Thank you Orchard & Seafire. Your simple Mod worked excellent. Next step - open in new window so the client does not leave our sites. Quote BG Making the internet community better. Knowledge is power.
Guest Posted May 15, 2003 Posted May 15, 2003 Thank you Orchard & Seafire. Your simple Mod worked excellent. I can't take credit for that mod...it was all Orchard's work 8) All I did was try to make more understandable for those of us PHP challenged folks.:wink: Sort of beta testing. Next step - open in new window so the client does not leave our sites. Yep. That is beyond my meager abilities, but hopefully someone out there will enlighten us. Phil Quote
Guest Posted June 11, 2003 Posted June 11, 2003 Open new window instead of redirect... To Easy: if (isset($cPath) && tep_not_null($cPath)) { if ( $cPath == 23 ) // replace 32 with your cPath number { ?> <SCRIPT LANGUAGE="JavaScript"> window.open ('http://www.ebay.com') </SCRIPT> <?php } } I spent hours reading rubbish @ php.net, then thought hmm may be javascript wala (open.window) Cheers Lee Quote
Guest Posted June 11, 2003 Posted June 11, 2003 only one small issue with a new window. in the background your original page still loads the default.php?cPath=23 categories path, customer get a new window and also the old one with "No products to list in this categorie" message. anyone have a solution for that? Quote
Guest Posted June 11, 2003 Posted June 11, 2003 Go-it, this is really cool.. if (isset($cPath) && tep_not_null($cPath)) { if ( $cPath == 23 ) // replace 23 with your cPath number { ?> <SCRIPT LANGUAGE="JavaScript"> window.open('http://www.ebay.com') // New Window to New Site onClick=window.location=('specials.php') // Redirect background (original) page to your specials or new site </SCRIPT> <?php } } It works.. Quote
Guest Posted June 11, 2003 Posted June 11, 2003 Wonderful! Only one change to suit my needs: ?> <SCRIPT LANGUAGE="JavaScript"> onClick=window.location=('default.php') window.open ('http://cgi6.ebay.com/ws/eBayISAPI.dll?ViewSellersOtherItems&userid=pobermarck') </SCRIPT> <?php Putting the onClick first makes the new window open in front of the old one, rather than being opened and then forced behind the old window when it redirects. (If that's clear :?: ) Thanks sooooo much to MaxiDvd! BTW, nice webpage. 8) Phil Quote
Guest Posted June 11, 2003 Posted June 11, 2003 Yeah good point seafire, i will change mine the way you suggested. its for my ebay shop aswell lol. Cheers Quote
mcbsolutions Posted June 23, 2003 Posted June 23, 2003 Hi, I've been trying to get this to work, yet I got confused with where the php tags start and end with the additional changes made that allows the page to open in a new window. Could someone post the lines from default.php from about line 15 to 30 showing an example. Thanks much! Steve Quote
Guest Posted June 23, 2003 Posted June 23, 2003 require('includes/application_top.php'); // the following cPath references come from application_top.php $category_depth = 'top'; if (isset($cPath) && tep_not_null($cPath)) { $categories_products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . $current_category_id . "'"); $cateqories_products = tep_db_fetch_array($categories_products_query); if ($cateqories_products['total'] > 0) { $category_depth = 'products'; // display products } else { $category_parent_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where parent_id = '" . $current_category_id . "'"); $category_parent = tep_db_fetch_array($category_parent_query); if ($category_parent['total'] > 0) { $category_depth = 'nested'; // navigate through the categories } else { $category_depth = 'products'; // category has no products, but display the 'no products' message } } } if (isset($cPath) && tep_not_null($cPath)) { if ( $cPath == 23 ) // replace 23 with your cPath number { ?> <SCRIPT LANGUAGE="JavaScript"> window.open('http://music.maxidvd.com.au') // New Window to New Site onClick=window.location=('default.php') // redirect background (original) page to your specials or new site </SCRIPT> <?php } } $categories_products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . $current_category_id . "'"); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_DEFAULT); ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> Quote
mcbsolutions Posted June 23, 2003 Posted June 23, 2003 :D Thanks again Lee!! That's two problems you helped me solve in one day! Regards, Steve Quote
mcbsolutions Posted July 20, 2003 Posted July 20, 2003 Lee or anyone else: How would I go about adding more than one link (in the categories area) to an external page? My guess is I would need another if statement, but since I'm no expert at this, I keep getting errors. Please post code. Thanks!! Steve Quote
Guest Posted July 20, 2003 Posted July 20, 2003 Hey mate, you just need to replicate the other info really. :wink: if ($category_parent['total'] > 0) { $category_depth = 'nested'; // navigate through the categories } else { $category_depth = 'products'; // category has no products, but display the 'no products' message } } } if (isset($cPath) && tep_not_null($cPath)) { if ( $cPath == 23 ) // replace 23 with your cPath number { ?> <SCRIPT LANGUAGE="JavaScript"> window.open('http://music.maxidvd.com.au') // New Window to New Site onClick=window.location=('default.php') // redirect background (original) page to your specials or new site </SCRIPT> <?php } } if (isset($cPath) && tep_not_null($cPath)) { if ( $cPath == 59 ) // replace 59 with your cPath number { ?> <SCRIPT LANGUAGE="JavaScript"> window.open('http://music.maxidvd.com.au') // New Window to New Site onClick=window.location=('default.php') // redirect background (original) page to your specials or new site </SCRIPT> <?php } } $categories_products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . $current_category_id . "'"); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_DEFAULT); Tested and works. Cheers MaxiDVD :lol: Quote
stretchr Posted August 5, 2003 Posted August 5, 2003 I'm trying to figure out how to get this to work in MS2. I found the line: if (isset($cPath) && strpos('_', $cPath)) { in index.php and appended to it to end up with: <?php if (isset($cPath) && strpos('_', $cPath)) { if ( $cPath == 26 ) // replace 32 with your cPath number { ?> <SCRIPT LANGUAGE="JavaScript"> window.open ('https://secure.comodo.net/products/frontpage?ap=Web-DJNETInstantSSL&area=SSL&product=43&reseller=y') </SCRIPT> <?php } I set up the category 26 as Free Trial SSL Certificate but when I click the link, nothing happens except I bring up the osC page for that category but I also get no errors so I'm wonding if I am at least close to having this right? BTW, that URL actually works if anyone wants to get a free trial COMODO InstantSSL certificate. Thanks, Stretchr Quote "It's a small world... But I wouldn't want to paint it!" Stephen Wright
Guest Posted August 5, 2003 Posted August 5, 2003 I tested this and it works, just one thing I should point out if the visitor is using a PopupWindow Stopper software - nothing will happen when they click the link, this is because the script uses java script:window.open as well as redirect. <?php if (isset($cPath) && tep_not_null($cPath)) { if ( $cPath == 21 ) { ?> // Change 21 To Your Categories cPath=Number <SCRIPT LANGUAGE="JavaScript"> window.open('https://secure.comodo.net/products/frontpage?ap=Web-DJNETInstantSSL&area=SSL&product=43&reseller=y') // New Window to New Site onClick=window.location=('<?php echo tep_href_link(FILENAME_DEFAULT);?>') // Redirect background to Homepage (With SID Intact) </SCRIPT> <?php } } ?> <?php if ($category_depth == 'nested') { $category_query = tep_db_query("select cd.categories_name, cd.categories_heading_title, cd.categories_description, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'"); $category = tep_db_fetch_array($category_query); ?> <table border="0" width="100%" cellspacing="0" cellpadding="0"> Cheers Lee Quote
stretchr Posted August 5, 2003 Posted August 5, 2003 I tested this and it works, just one thing I should point outif the visitor is using a PopupWindow Stopper software - nothing will happen when they click the link, this is because the script uses java script:window.open as well as redirect. <?php if (isset($cPath) && tep_not_null($cPath)) { if ( $cPath == 21 ) { ?> // Change 21 To Your Categories cPath=Number <SCRIPT LANGUAGE="JavaScript"> window.open('https://secure.comodo.net/products/frontpage?ap=Web-DJNETInstantSSL&area=SSL&product=43&reseller=y') // New Window to New Site onClick=window.location=('<?php echo tep_href_link(FILENAME_DEFAULT);?>') // Redirect background to Homepage (With SID Intact) </SCRIPT> <?php } } ?> <?php if ($category_depth == 'nested') { $category_query = tep_db_query("select cd.categories_name, cd.categories_heading_title, cd.categories_description, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'"); $category = tep_db_fetch_array($category_query); ?> <table border="0" width="100%" cellspacing="0" cellpadding="0"> Cheers Lee Thanks, Lee. The problem with using javascript is something I don't know how I can get around in a situation such as this. I'll give it a go. Cheers, Stretchr Quote "It's a small world... But I wouldn't want to paint it!" Stephen Wright
sinbad Posted September 9, 2003 Posted September 9, 2003 First I like to say thanks to all of you who shared this information. I have been trying to get it to open in new window using the java script suggestion however I kept receiving parse errors and such. If someone could help me out with this I would appreiciate it. // the following cPath references come from application_top.php $category_depth = 'top'; if (isset($cPath) && tep_not_null($cPath)) { if ( $cPath == '50_52' ) // replace 50_52 with your cPath number { header( 'Location: http://www.sitename.com' ); // replace with your external URL exit; } Quote Sinbad "Mine is not the only way, mine is just another way
Guest Posted September 10, 2003 Posted September 10, 2003 great thread. covers numerous different ways and places for the window. what about making it pop open with certain dimensions, no scroll bar, etc etc? Quote
Guest Posted September 10, 2003 Posted September 10, 2003 sinbad and dehdmtw This script allows for customizing the size of the Window, the Position - left right top ect, if you dont want scroll bars simply change: scrollbars=yes to scrollbars=no <?php if (isset($cPath) && tep_not_null($cPath)) { if ( $cPath == '1_6' ) { // Change 1_6 To Your Categories cPath Number ?> <SCRIPT LANGUAGE="JavaScript"> window.open("http://www.maxidvd.com.au","height=200,width=200,left=80,top=80,scrollbars=yes"); // New Window to New Site onClick=window.location=('<?php echo tep_href_link(FILENAME_DEFAULT);?>') // Redirect background to Homepage (With SID Intact) </SCRIPT> <?php } } ?> sinbad I think you code placement is responsible for the error, javascript/php clash, try using the code above - just remeber to place it after a ?> php closing tag, somewhere towards the top of the page, but below the categories code- $category_depth = 'top'; if (isset($cPath) && tep_not_null($cPath)) { $categories_products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'"); $cateqories_products = tep_db_fetch_array($categories_products_query); if ($cateqories_products['total'] > 0) { $category_depth = 'products'; // display products } else { $category_parent_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$current_category_id . "'"); $category_parent = tep_db_fetch_array($category_parent_query); if ($category_parent['total'] > 0) { $category_depth = 'nested'; // navigate through the categories } else { $category_depth = 'products'; // category has no products, but display the 'no products' message } } } ?> <?php if (isset($cPath) && tep_not_null($cPath)) { if ( $cPath == '1_6' ) { // Change 1_6 To Your Categories cPath Number ?> <SCRIPT LANGUAGE="JavaScript"> window.open("http://www.maxidvd.com.au","height=200,width=200,left=80,top=80,scrollbars=yes"); // New Window to New Site onClick=window.location=('<?php echo tep_href_link(FILENAME_DEFAULT);?>') // Redirect background to Homepage (With SID Intact) </SCRIPT> <?php } } ?> Should work fine.. Cheers MaxiDVD Quote
Recommended Posts
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.