• Resolved glondono

    (@glondono)


    Hi
    I was wondering if there is a php function I can call to add an item in the shopping cart directly. Note that I’m not referring the function to print the add to cart button.

    Looking into the code it seems that may be need to change the session directly if so, can you give me some guidelines?

    We are considering buying the eStore plugin, and if so, it is possible to do this there?

    Thanks

    https://www.ads-software.com/plugins/wordpress-simple-paypal-shopping-cart/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author mra13

    (@mra13)

    If you give me an example of what you are trying to do then I should be able to better understand your requirement and give you an answer.

    eStore has an option that allows you to add item to the cart using a URL/link which will probably do the job.

    Thread Starter glondono

    (@glondono)

    I’m displaying a list of classes from another system and I’m using the shortcode to place a add to cart button for each.

    Each class will also have a donate button that will redirect to a page where a person can state the amount and also will have the add to cart button to add it to the cart (with the amount specified).

    I got the redirection and the form in place, also I’m listening for the POST of that form with the amount to donate information but what I’m missing is how to add that amount to the cart in that POST call.

    Thanks for your help.
    The support has been excellent for a free product.

    Plugin Author mra13

    (@mra13)

    I have replied to the question you asked on our support forum. We will handle it over there.

    Thread Starter glondono

    (@glondono)

    Hi,

    Instead of listening for the post back and add the product on php, I tried to recreate the form the Add to Cart button creates with an input visible for price, something similar to this

    <form id="form1" name="form1" method="POST" action="" onsubmit="return ReadForm(this, true);">
    <label for="price">Amount to Donate</label>
    <input id="price" name="price" type="number" step="50.00" value="50">
    <input type="hidden" name="shipping" value="0">
    <input type="hidden" id="classid" name="classid" value="1234">
    <input type="hidden" name="addcart" value="1">
    <input type="hidden" name="cartLink" value>
    <input type="hidden" name="product_tmp" value="S1234-Class ABC">
    <input type="hidden" name="item_number" value="">
    <input type="submit" value="Add to Cart">
    </form>

    on submit, the item is added to the cart correctly and the price and total are also correct but there is no description (no S1234-Class ABC), just a blank line.

    Am I missing a field?

    Thanks

    Plugin Author mra13

    (@mra13)

    You need to have the item name in the “wspsc_product” field. see example below:

    <input type=”hidden” name=”wspsc_product” value=”S1234-Class ABC” />

    Thread Starter glondono

    (@glondono)

    Thanks, worked like a charm

    Plugin Contributor mbrsolution

    (@mbrsolution)

    @glondono great to hear ??

    Can you mark this support thread as resolved.

    Thank you

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Add item to cart on php’ is closed to new replies.