Jump to content

Paypal store


grucker

Recommended Posts

Good evening. I have managed to get the store completed and am now building a website to my specifications. Everything went fine until I tried to add a link to give more information on a product item. The following is the content in the xml catalog.

 

More Information

 

If i remove all the aref and just put more information that shows when the whole is used nothing shows.

I tried a form but couldnt get it to open in a new window.

 

Hope you will help.

Kindest regards

David

Link to comment
Share on other sites

So you're doing something like this within the XML catalog, and nothing is showing up when you view that product in your HTML page?

 

Your text here...

 

Yes I have a limited description and want to write a link to open a larger description using java script to open in a seperate page showing a fuller description and larger picture in a seperate file.

 

Would it help if I showed you the site?

 

Regards

David

Link to comment
Share on other sites

Either that, or at least show the snippet of code that you are trying to use.

 

below is the xml file and following is a link to the page showing the result. The page source

shows the div

and but it is blank in between

 

Bergamot_Grapefruit

Bergamot & Grapefruit

One of a truly remarkable selection of shower

gels that are made to revitalise and cleanse.

http://www. ultimateskin care.org.uk/mulberry/images/bandg.png

bergamot grapefruit ultimate skin care poppy red naturals organic Lavera Akamuti Eco friendly, Natural organic cosmetics, Organic Beauty Products, Natural skin care, Organic baby products, Organic Skin Care, Organics

200ml

6-99

More Information

Link to comment
Share on other sites

So, at the moment, no matter what you put within the in the XML file (link, text, etc), it isn't showing up?

 

Sorry I may have misled you. If I remove the aref and leave the More Information then it shows.

Just when I try to post the href with javascript things disappear

 

Would their be any other way to post a link?

 

Regards

David

Link to comment
Share on other sites

Ah, got it. Here's the thing -- XML is getting confused, since you're placing HTML tags within XML tags, and it can't distinguish between the try.

 

Try one of these two methods (I believe the first should work, not completely sure about the second):

 

Escaping the tags

<a href="JavaScript:newwindow(850,660,'http://www.sites4eyes.co.uk');">More Information</a>

 

or using a CDATA

More Information]]>

 

http://stackoverflow.com/questions/1398571/html-inside-xml-should-i-use-cdata-or-encode-the-html

http://www.quackit.com/xml/tutorial/xml_cdata.cfm

Link to comment
Share on other sites

Ah, got it. Here's the thing -- XML is getting confused, since you're placing HTML tags within XML tags, and it can't distinguish between the try.

 

Try one of these two methods (I believe the first should work, not completely sure about the second):

 

Escaping the < and > tags

<a href="JavaScript:newwindow(850,660,'http://www.sites4eyes.co.uk');">More Information</a>

 

or using a CDATA

<a href="JavaScript:newwindow(850,660,'http://www.sites4eyes.co.uk');">More Information</a>

 

http://stackoverflow.com/questions/1398571/html-inside-xml-should-i-use-cdata-or-encode-the-html

http://www.quackit.com/xml/tutorial/xml_cdata.cfm

 

 

What a delightful fellow you are. I have asked your advice on several occasions now and you have come up trumps every time.

 

Both solutions work by the way, which way would you recommend I use to save any more problems?

 

Once again Thanks very much

Kindest regards

David

Link to comment
Share on other sites

Both solutions work by the way, which way would you recommend I use to save any more problems?

 

If both work, it's up to your personal preference... I think that the CDATA method is a bit more readable, and there is less chance of an error in your code.

 

I should also mention -- I noticed this in your code. I'm not sure what's going on, but I'd double check the code surrounding where you insert your images (this

tag wraps each of your product images on http://www.ultimateskincare.org.uk/mulberry/poppyrednaturals.php)

 

[b]
[/b] 

 

The ;="" bit is odd and may end up causing you errors.

Link to comment
Share on other sites

It never rains but it pours. I am not sure if this the correct place for this problem and another user appears to be having a similar problem, but here goes. Did all the previous corrections and added more photos and links to other pages. Marvelous I thought. Tested on Firefox, Google Chrome, Safari and Netscape, all with similar results looking good. Then I used I E. the first load of pictures downloaded then nothing. The page source shows the links and everything is identical to other browsers but no photos.

 

http://www.ultimateskincare.org.uk/mulberry/poppyrednaturals.php

 

Is the page with added links, would you take a look and give me the benefit of your advice. Do I need extra code for I E?

 

Kindest regards

David

Link to comment
Share on other sites

The first thing I would do is work on these errors: http://validator.w3.org/check?uri=http://www.ultimateskincare.org.uk/mulberry/poppyrednaturals.php

 

It looks like you have some missing closing tags (specifically missing div and table tags), most likely within your product loop. That could be causing issues. I know it looks like there are a lot of errors, but fix a couple lines within your code and most of those should fix themselves.

Link to comment
Share on other sites

Once again I followed your advice and the problem was sorted. A closed div that wasnt opened and a > missing from a

The code=html code is either side of this   

showing. I removed this and it verified. I then removed it from one of the earlier errors and it works so is this really necessary. Then I inserted

into the form and got the green light. Feeling chuffed I checked css, ok. Section 508, ok. Then wai and got failure with the following

 

Rule: 13.1.2 - All Anchor elements are required not to use the same link text to refer to different resources.

 

* Failure - Anchor Element at Line: 331, Column: 12

* Failure - Anchor Element at Line: 552, Column: 12

* Failure - Anchor Element at Line: 594, Column: 12

* Failure - Anchor Element at Line: 637, Column: 12

* Failure - Anchor Element at Line: 679, Column: 12

* Failure - Anchor Element at Line: 852, Column: 12

* Failure - Anchor Element at Line: 1025, Column: 12

 

Whats this all about?

 

Thanks again old chap any clues will be appreciated.

 

Kindest regards

David

Link to comment
Share on other sites

I'm not sure -- seems like there may be an error in your above post? (in the code area), so I really can't comment on the first issue. If you removed the code and it seems to be working fine and validates, don't worry about it. If the "&" doesn't cause issues within the XML file, but doesn't validate, replace it with "&" instead.

 

I wouldn't worry about the WAI error issue too much. Basically, it just says that text links shouldn't contain the same anchor text but link to different locations.

 

example:

 

your link
your link

Link to comment
Share on other sites

The site verified for wai after heeding your advice. Then I checked links and the java script links were a problem when javascript is switched off. I tried coding noscript in to the script as follows and this works up to a point although it does leave the inoperable java script link. However it now fails on xhtml strict. Where exactly should I insert the noscript code? Non rude answers only please.

 

Regards

David

 

 

<a href="JavaScript:newwindow(650,800,'http://www.ultimateskincare.org.uk/mulberry/extrainfo/rejuserum.php');">More Information on this Serum<br/><noscript><a href="http://www.ultimateskincare.org.uk/mulberry/extrainfo/rejuserum.php">javascript is disabled on your browser click here for more information</a></noscript></a>

Link to comment
Share on other sites

Once again the ideal answer. Was that a form of javascript? Anyway everything now validates everyway possible so I finally moved on to the cart. So I had put hyphens instead of dots to split pounds and pence and when I got that sorted I noticed everytime I add a new item to the cart it adds one to the previous amount. So for six items added, five are for two items. I am fairly sure I havent done anything to the cart since I did the course. Any pointers for me?

 

Kindest regards

David

Link to comment
Share on other sites

Once again the ideal answer. Was that a form of javascript? Anyway everything now validates everyway possible so I finally moved on to the cart. So I had put hyphens instead of dots to split pounds and pence and when I got that sorted I noticed everytime I add a new item to the cart it adds one to the previous amount. So for six items added, five are for two items. I am fairly sure I havent done anything to the cart since I did the course. Any pointers for me?

 

Kindest regards

David

 

 

Just noticed it counts and appears to work correctly in IE so looks like firefox is my problem. Hope you can help.

 

Regards

David

Link to comment
Share on other sites

Tried again this morning and it appears to be working ok in firefox so maybe I had a cache problem.

 

Now then, I have two xml files with different types of products. How do I code the functions to accept the second file and add it to the cart. I have tried duplicating what I already had but get error messages when I try to open the page of goods for sale. If you look at the link the top eight items work fine the rest are in a different file and do not add to the cart.

Advice please.

Kindest regards

David

Link to comment
Share on other sites

Unfortunately I'm not really familiar enough with this particular tutorial to be able to give you advice on working with multiple XML files.

 

My guess, however, is that you'd need to look at the code for the "addToCart.php" page, and see what it's doing with the id value that gets passed when you click the "add to cart" button. You probably need to add a reference to the second XML file at some point within that code. (I can't really tell you where unless I see the code you're working with.)

Link to comment
Share on other sites

Unfortunately I'm not really familiar enough with this particular tutorial to be able to give you advice on working with multiple XML files.

 

My guess, however, is that you'd need to look at the code for the "addToCart.php" page, and see what it's doing with the id value that gets passed when you click the "add to cart" button. You probably need to add a reference to the second XML file at some point within that code. (I can't really tell you where unless I see the code you're working with.)

 

Thanks for looking for me. It seems strange that the author of the course didnt explain how to use multiple xml pages. I thought a page for each type of product would have kept the site more manageable and easier to edit. Seems I have wasted our time.

 

Thanks ever so much for your help at least I have learnt lots of pointers from you which have given me more of an insight to php.

 

Kindest regards

David

Link to comment
Share on other sites

Thanks for looking for me. It seems strange that the author of the course didnt explain how to use multiple xml pages. I thought a page for each type of product would have kept the site more manageable and easier to edit. Seems I have wasted our time.

I'm not saying give up on it, I'm just saying that I would need to see the code you are working with.

 

I don't think the tutorial was really intended to power a large store though -- it's better intended for something small with just a couple products, where there really isn't a need for multiple categories, more advanced features, etc. There are a lot of other options out there for a more fully featured store... Magento, Wordpress ecommerce, shopp or PHPurchase plugins, FoxyCart, etc.

Link to comment
Share on other sites

Must admit I was a bit dispirited but as you said you may be able to help if you saw the code here goes.

I have two xml files catalog.xml and catalogshort.xml I have added both to the globals.

 

The files load to my page but I cannot suss out

function set_shopping_cart($cart) I have tried adding the catalogshort but failed with every attempt. I thought it would be easy but I do not know how.

 

<?php

/** Define Globals **/

define('STORE_XML_SHORT_FILE' , 'catalogshort.xml');

define('STORE_XML_FILE' , 'catalog.xml');

define('PAYPAL_BUSINESS', 'dmaxey_1261514279_biz@btinternet.com');

define('PAYPAL_URL' , 'https://www.sandbox.paypal.com/cgi-bin/webscr');

 

/** DEFINE REFERENCES **/

require_once('functions/templates.php');

 

require_once('classes/ShoppingCart.php');

 

/** Functions **/

SESSION_START();

function get_xml_catalog()

{

return new SimpleXMLelement(file_get_contents(STORE_XML_FILE));

}

function get_xml_catalogshort()

{

return new SimpleXMLelement(file_get_contents(STORE_XML_SHORT_FILE));

}

function get_shopping_cart()

{

if (! isset($_SESSION['cart']))

return new ShoppingCart();

else

return unserialize($_SESSION['cart']);

 

}

 

function set_shopping_cart($cart)

{

$_SESSION['cart'] = serialize($cart);

}

 

function product_exists($product_id)

{

foreach(get_xml_catalog() as $product)

 

{

if ($product->id == $product_id)

 

return true;

}

return false;

}

function get_item_cost($product_id)

{

foreach(get_xml_catalog()as $product)

{

if ($product->id == $product_id)

return $product->price;

}

throw new Exception('item not found:'. $product_id);

}

?>

Link to comment
Share on other sites

OK, I've figured out one possible solution, but I don't think it does exactly what you want it to do.

 

First off, I deleted these lines:

function get_xml_catalogshort()
{
return new SimpleXMLelement(file_get_contents(STORE_XML_SHORT_FILE));
}

 

And I updated the function get_xml_catalog() to this:

function get_xml_catalog() {
   $file = '' .
       file_get_contents(STORE_XML_FILE) .
       file_get_contents(STORE_XML_SHORT_FILE) .
       '';

   return new SimpleXMLElement($file);
}

 

And lastly, I edited the xml files to remove the opening "" and closing "".

 

These changes work, potentially allowing you to use multiple XML files easily, but when you go to the view page, there is no separation of the individual categories -- all of the products are displayed together in a long list.

 

There are ways around this, of course, though it would mean some playing with the files. Probably the easiest way would be to add a "category" tag within the XML file, and then some editing of the functions.php file to adapt to the new schema. It would take some time and experimentation.

Link to comment
Share on other sites

To be clear, the reason why your version isn't working is that the add to cart function first checks if the product exists (accessing the function product_exists($product_id)). The function product_exists($product_id) then checks against the XML file (the get_xml_catalog() function within the line "foreach(get_xml_catalog() as $product)"). And the get_xml_catalog() function then loads the original XML file with this function "file_get_contents(STORE_XML_FILE)". It's only loading one XML file, not all of them.

 

Now, you could write duplicate functions for every separate xml file you add... That seems like a terrible pain though, and will only lead to confusion down the road if you need to come back and make modifications later.

Link to comment
Share on other sites

I suppose you could modify "function product_exists($product_id)" to do something like this:

 

function product_exists($product_id)

{

foreach(get_xml_catalog() as $product)

{

if ($product->id == $product_id)

 

return true;

}

foreach(get_xml_catalogshort() as $product)

{

if ($product->id == $product_id)

 

return true;

}

 

return false;

}

 

And that would fix the product_exists function to work with multiple XML files. You'd still need to edit "function get_item_cost($product_id)" to also use the "get_xml_catalogshort()" function, similarly to what I did above. Any time you needed to add additional XML files, you'd need to duplicate some of your functions (specifically "get_xml_catalog()") and also add the new function to "function get_item_cost($product_id)" and "function product_exists($product_id)".

 

All in all, I wouldn't suggest it. Unnecessary duplicated code is bad code, and it'll only lead to headaches later when you can't figure out why something isn't working as it should.

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...