Jump to content

Recommended Posts

Hello, I'm a cs student (2nd year) this year has been a disaster for us the students(studying over zoom and shit), I have a tiny tiny project that a have to finish in the next 24 hours, we made a small sample website using html and js, and now we need to switch it to php language and make the site responsive and later on add SQL. I would very much appreciate if someone can help me for couple of minutes over zoom and help me complete it. All I have left is echo the products from an array with a loop and make a php table that will put my items to my cart.

It's my first time here..hope there is some good people here :)

Edited by requinix
added thread title

This is a forum for posting problems and getting answers. It's not good for soliciting individual and personalized help from a single person. You're much more likely to get help by posting your code and asking specific questions instead of hoping someone will come along and decide that they want to do a video chat with a complete stranger.

Ready to do that? If all you have left is this thing with a loop and table then this should be pretty quick and easy.

  • Like 1

Ok sounds good my friend :)

so here is an example for one item from my store ' all the other items are alike,

also here is my array the I want to use in order to echo the items in my store  , 

I just noticed that i said table but i meant form, what I need to do is make a form in a sepperate php file that will have only quantity of each item and later on will send it to my shopping cart with post request. sorry for my bad english , I can explain myself better if needed.

in the last picture is my website i need to change the add to cart button to quantity and in the bottom of the page add button purchase that will send me to my cart with the items selected.

 

 

Item.png

array.png

WebSite.png

@Niksou, when you're posting code, do so as text not images.  Copy your code then use the Code button (<>) in the editor to create a code block and paste your code there.  If you don't post it as text, nobody can copy it to a file and test it in order to help you, so they will likely just skip your thread and you'll get no help at all.

If you want to change your Add to Cart button to a quantity input then change the <button> tag to an <input> tag of type number.  Add your new add to cart button where you want it.  After that you'll have to figure out how to update the code that handles your cart to work with the new design.

If you have a specific problem you are stuck on then post about it, but a post like "I want to do <some generic thing>" followed by a bunch of code is generally not well received.

 

  • Like 1

The first thing I would have to see is the code (in text form) of displayCart. What does the 0 mean? Can it add products to the cart?
Another thing is the PHP script you have for adding products to the cart. Is that ready to use? What POST data do you need to send?

A simple change to make now would be to add the quantity input next to the button. For how many to add to the cart.

  • Like 1

hello , sorry for my inexperience in forums, any way here is my git will all the code , https://github.com/niksou/Web-site

display cart 0 means that i add the item (id=0) to cart using js, the post data i need to send is product name price and quantity to to cart page which will be a seperate page that displays all added to cart items withtheir amount and their total price. im not sure where or how to place the form that will add the items to my cart using post method.

in general , just send the items from my cart to the cart.php page

 

All you should be sending to the cart is product id and quantity. Never allow the user the specify their own price, otherwise you'll end up selling everything for 0.01. On the cart page, query the database to get price and description.

also in the header part I have this function :written in js

function updateSum(price) { $('#sum').innerText = parseInt($('#sum').innerText) + price }

that supposed to update the sum here in header part :

Total:<span id="sum"></span>$

but for some reason nothing changes

carts.png

$('#sum').innerText

That syntax mixes jQuery and plain Javascript which you cannot do.  $('#sum') creates a jQuery object, but .innerText is a DOM property in plain javascript. 

The jQuery way to read/set the text value of an element is with the .text() method.

 

  • Great Answer 1
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.