SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Evangelist
    Join Date
    Mar 2011
    Posts
    423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can PHP achieve JavaScript results? & Confusing customers with delivery charges!

    Hi,

    I am looking at Girlznight: Viewing Cart Items shopping basket. I need a box where the customer selects delivery option. This site updates the cart automatically when the delivery is chosen. I believe it is done with JavaScript. I want to avoid JavaScript - can I achieve this with just PHP? So when the delivery type is chosen the cart updates either with or without loading the page again. I am afraid this might only be possible with JavaScript!

    First they ask for country to be selected:
    Select/Change Delivery Country:
    <br>
    <select id="intZoneID" name="intZoneID" onchange="dco();UpdateCart();">
    <br>

    Second they ask for delivery type:
    Select/Change Delivery Type:
    <br>
    <select id="intDeliveryID" onchange="dco();UpdateCart();" name="intDeliveryID">
    </div>

    The onchange is JavaScript I think.


    I also have a dilemma with different pricing for delivery depending on if the customer buys a product or accessory. I could make it so if the customer adds/buys:

    Accessory only: 2.95 standard postage (with other options for quicker delivery)
    Product only: 5.99 standard postage (with other options for quicker delivery)
    Product and Accessory: 5.99 standard postage (with other options for quicker delivery)

    But it might be complicated explaining the difference in delivery charges to potential customers. So if you have any ideas I am all ears.

    Matt.

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,500
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by MatthewBOnline View Post
    This site updates the cart automatically when the delivery is chosen. I believe it is done with JavaScript. I want to avoid JavaScript - can I achieve this with just PHP? So when the delivery type is chosen the cart updates either with or without loading the page again. I am afraid this might only be possible with JavaScript
    For an automatic update without loading the entire page again you need JS.

    The onchange is JavaScript I think.
    Yes

    I also have a dilemma with different pricing for delivery depending on if the customer buys a product or accessory. I could make it so if the customer adds/buys:

    Accessory only: 2.95 standard postage (with other options for quicker delivery)
    Product only: 5.99 standard postage (with other options for quicker delivery)
    Product and Accessory: 5.99 standard postage (with other options for quicker delivery)

    But it might be complicated explaining the difference in delivery charges to potential customers. So if you have any ideas I am all ears.

    Matt.
    Are you asking for a technical solution? Or would you like other peoples opinions about how to handle delivery charges from a marketing point of view?

  3. #3
    SitePoint Evangelist
    Join Date
    Mar 2011
    Posts
    423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK - So what PHP code would make the page load again, when the postage is chosen from the drop-down menu?

    Regarding the postage I suppose I want a marketing viewpoint but anyone with experience technically or marketing might be able to suggest something better than what I have at the moment which is a standard rate of 5.95. If you were a customer buying something for 9.95 or 14.95 you might think twice. But it can be tricky explaining different delivery charge rates - I was thinking of automating calculation without explaining much to the customer but there will be a few customers who buy a product one day and an accessory another day and they will think 'the postage charge is different - why??' It will be enough to explain the different speeds of delivery (next day before 5, next day before 1, next day before 9, saturday delivery, etc.).

    Matt.

  4. #4
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,500
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by MatthewBOnline View Post
    OK - So what PHP code would make the page load again, when the postage is chosen from the drop-down menu?
    My first answer was a bit too short. For any automatic update you need JS. For an update (automatic or not) that loads only part of the page you need JS.

    If you don't want to use JS, the user will have to send the form.

  5. #5
    SitePoint Evangelist
    Join Date
    Mar 2011
    Posts
    423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I thought maybe when the user selects the choice from the drop-down list the page would reload and then the drop down menu would set say $postage = 3.99 (depending on selection) and the page would reload and display 3.99 postage and add $postage to the total.

    It sounds feasible as long as it is possible to set $postage depending on the selection in the drop-down menu. And the selection needs to reload the page too (when selected-submit form??). I thought this would be possible!?

    Matt.

  6. #6
    SitePoint Guru aamonkey's Avatar
    Join Date
    Sep 2004
    Location
    kansas
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What guido is saying is that you can't make the page reload by selecting an option in a select box without JavaScript. Basically you can't change or refresh pages in response to a user action unless they click on a link or submit a form.....unless you use JavaScript.
    aaron-fisher.com - PHP articles and more

  7. #7
    SitePoint Evangelist
    Join Date
    Mar 2011
    Posts
    423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    right - nice to get a second confirmation that it is not possible.

    If I added a small piece of JAVA SCRIPT for this drop-down menu would it be worth doing? If a customer did not enable Java-Script would it be possible to add it on the confirmation page (the page following the basket)?

    So if the user enables Java Script it appears instantly in the basket and they also see confirmation on the next page. (90% of users)

    If a user disables Java Script the drop-down window displays the choice but it is not updated instantly. When they click to go to the next page their choice is recognised and their total is displayed on the following page. (10% of users)

    Is this reasoning/design concept used quite commonly. Will it work as I describe for the 90% and 10% of users?

    Matt.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •