Scratch Silver III
Scratch Silver II
SCRATCH SILVER I
SCRATCH GOLD III
1 of 3

4.04 Purchases

Purchases

The seller sprite needs to:

  • ask if the customer is ready to pay for the items
  • take payment
  • get ready for the next customer

When they have finished choosing items, the customer will click on the seller sprite to pay.

Tell the customer how much their items will cost.

Add a payment sound to your seller sprite so the customer knows that payment is taking place.

The add a sound icon

Select the sprite that you want to have the new sound, then select the Sounds tab. Each sprite starts with a default sound:

The Sounds tab open in the Scratch editor.

Scratch has a library of sounds that you can add to your sprites. Click on the Choose a Sound icon to open the Sound Library:

The 'Choose a Sound' icon highlighted.

To play a sound, hold your mouse cursor (or your finger, if you are using a tablet) over the Play icon:

'Play' icons.

Click on any sound to add it to your sprite. You will be taken straight back to the Sounds tab and you will be able to see the sound that you have just added:

A newly inserted sound in the Sounds tab.

If you switch to the Code tab and look at the Sound blocks menu, you will be able to select the new sound:

The 'Sound' blocks menu, with the new sound available for use within blocks.

Tip: You can also add sounds to the Stage.

Add the play sound until done block to your script.

Finish the sale. Set total back to 0 after payment, say goodbye and broadcast next customer.

You might want to give the customer the option to cancel their shopping.

Ask Would you like to pay or cancel?. Add an If block for answer = pay and inside it put your existing payment blocks.

Add a second If block for answer = cancel and inside it add code to cancel the order.

To make sure your customer has items in their basket before paying, you can insert an if...else block.

If total > 0  then insert your existing script.

Else say a helpful message.

Test: Test your project and make sure:

  • The customer can check out with the correct sound effects
  • The total gets set back to 0 after a customer pays or cancels.

Debug: You might find some bugs in your project that you need to fix.

Here are some common bugs:

You have quite a lot of sprites in your project. Make sure the when this sprite clicked script is on your seller sprite.

Tip: If you have added it to the wrong sprite, you can drag the code to the seller sprite, then delete it from the other sprite.

Make sure your say block has the total variable block, not the word total.

When you join two pieces together, you need to add a space at the end of your first piece of text or at the beginning of your second piece of text.

These have a space at the end of the first part of the join:

Tip: Compare your code with the code examples. Are there any differences that shouldn’t be there?

×
×

Cart