Product custom variant property for "Buy with PayPal" button? - shopify

We can add a custom variant property to any product by adding hidden input(s) in the add to cart form on product pages in main-product.liquid (Dawn theme):
<form method="post" action="/cart/add" id="product-form-template--17081662406963__main" accept-charset="UTF-8" class="form" enctype="multipart/form-data" novalidate="novalidate" data-type="add-to-cart-form">
<input type="hidden" name="form_type" value="product">
<input type="hidden" name="utf8" value="✓">
<input type="hidden" name="id" value="44030441193779">
<input type="hidden" name="properties[Size]" id="custom-size" value="5T">
<input type="hidden" name="properties[Color]" id="custom-color" value="Blush Pink">
</form>
It works well with the Add to cart and Buy it now buttons that the custom properties Size and Color are successfully relayed to checkout and eventually to order information.
You can try it here: https://www.meblush.com/products/off-shoulder-corset-black-lace-tulle-court-mermaid-wedding-dress
This product has NO variants defined at all but we are able to select custom options (Size, Color) for it for checkout.
However, this doesn't seem to work for the Buy with PayPal button and the custom properties are NOT transferred to the popup PayPal checkout window.
If you try this product with REAL native variants: https://www.meblush.com/products/princess-ivory-lace-blush-pink-tulle-flower-girl-dress
And click the Buy with PayPal button, the popup PayPal checkout window does have the product name appended with the variant selected, e.g. "- 2T / Blush Pink".
But with our custom property hidden input Size and Color, the PayPal checkout window isn't notified of the custom properties in the form we added.
My question is, how can we make it work for the "Buy with PayPal" button as well?
I looked through the HTML and there doesn't seem to have any variable to feed the custom properties to PayPal?

Related

How to replace Vendor with Add to Cart button on Slick Slider - Shopify Debut theme?

How can I remove the Vendor name and replace with an Add to Cart button on this Slick carousel? This is for the Shopify Debut Theme. Thanks for your help :)
Follow the below steps for Debut theme for Add to cart button on product grid.
In Shopify Admin select "Online Store" and click on Themes.
Choose your main theme.
Click the . . . on the top left-right (see below) and hit "Edit code" option.
Open Snippets -> "product-card-grid.liquid" File and paste below code at the end of the page code.
Here is that code:
<form method="post" action="/cart/add">
<input type="hidden" name="id" value="{{ product.variants.first.id }}" />
<input min="1" type="number" id="quantity" name="quantity" value="1"/>
<input type="submit" value="Add to cart" class="btn" />
</form>

How can I display additional order information on checkout page through cart?

I need to display additional order information on checkout page through cart page.
Can any one help me for this.
You can add additional order information on checkout page through cart attribute.
For this add below code in shopify cart.liquid file between the <form> and </form> tag. The form field will appear wherever you place the code.
<p class="cart-attribute__field">
<label for="your-name">Your name</label>
<input id="your-name" type="text" name="attributes[Your name]" value="{{ cart.attributes["Your name"] }}">
</p>
You can also check this link : https://ui-elements-generator.myshopify.com/pages/cart-attribute
Use {{ cart.attributes["Your name"] }} on your checkout.liquid to display the desired option.

Validations not working in ODOO website

I have created a template and a controller for it in ODOO v8. Following is the template:
<template id="myTemplate">
<t t-call="myTemplateHeader"/>
<div class="myClass">
<form action="/myControllerAction" name="myTemplateForm">
<input type="text" id="name" name="name"/>
<input type="text" id="lname" name="lname"/>
<input type="text" id="email" name="email"/>
<input type="submit" value="Submit"/>
</form>
</div>
</template>
And I have written a controller for the action /myControllerAction.
#http.route(['/myControllerAction'], type='http', auth="public", website=True)
def index(self, **post):
data = {}
# some action here
# to submit and fetch values
request.website.render("my_module.mySecondTemplate", data)
I have added validations on the fields in the form so that one cannot submit the form without entering the values in all the text fields given. The validations in JS works, it shows an alert message when the text fields are blank(one alert for each text field). But, after clicking the OK for the alert message of email field, it submits the form even when the field is empty. I have checked the issue and found that the problem exists only if I provide
<input type="submit" value="Submit"/>
and it will be solved if I am using
<input type="button" value="Submit"/>
But I have to make some calculations in the controller and need to retrieve some data from the database to show on the next page. For this, type="button" cannot be used as it just submit the form and redirect to next page without making a call to the controller function. type="submit" will make the call to the controller, but validations are not working as described earlier. Also submitting the form using onclick event of the button in javascript won't call the controller. I want validations on the form and then call the controller(on submit). Is there any way I could implement this in ODOO v8?
For making fields mandatory in ODOO templates, the attribute required="required" can be used on input fields.
<input type="text" id="name" name="name" required="required"/>

Am trying to create an item in the cart for a Big Commerce store and it keeps redirecting to the item page I just left

We are working on behalf of a Big Commerce store owner and are trying to add items to the shopping cart by posting the same data that the regular item page posts, except it is done by an external program on another server. This is because we intercept the post (which is done via a postbackurl on an iframe included in the item page that allows the customer to customize the item)... and then repost the same data to the cart.
This was working in our test store but not in the client store. I'm wondering if the difference is that when the item page posts, the Origin header is of course from that store. WHen I post it from my program, the origin header is different. How can I tell what the real issue is?
Is there a setting in Big Commerce that allows posts from another origin?
Or, how do I add a store product from an external program into the Big Commerce cart?
Thanks,
Cindy
Yes, the product has options... I am not posting them in the form below but it makes sense that I should.
Here is a sample of my code:
<script type="text/javascript">
function submitform() {
document.forms["redirectpost"].submit();
}
</script>
</head>
<body onLoad="submitform();">
<form name="redirectpost" method="post" action="http://eystudios8.mybigcommerce.com/cart.php" enctype="multipart/form-data">
<input type="hidden" name="action" value="add">
<input type="hidden" name="product_id" value="211">
<input type="hidden" name="variation_id" vale="">
<input type="hidden" name="currency_id" value="">
<input type="hidden" name="qty[]" value="1">
<input type="hidden" name="ProductFields[1]" value="<?php echo $docsession; ?>">
<input type="submit" value="" style="display:none;">
</form>
I also have a configurable field I am attempting to post the docsession to.
Cindy
Adding this question:
I see that I need to post the options in my form - how do I know what field name to call each option? There are about 15 options I need to forward to the cart page. Cindy

Testing PayPal buttons

I generated a vb.net website to sell some quantity of a book. it's a vb.net site using a SQL server backend. I modeled the book's order form on the paper form the company was using. The form allows customers to specify: name, organization, address, city/state/zip, and quantity.
Once the form is complete, they submit the form to another page which records the form values in a database. I then have them press the add to cart button which is supposed to upload the cart information to paypal for checkout. For some reason the cart opens empty without any errors.
Here is my add to cart info:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="business" value="XXXXXX#XXX.XXX" />
<input type="hidden" name="item_number_1" value="2015" />
<input type="hidden" name="item_name_1" value="2015 Catholic Directory" />
<input type="hidden" name="amount_1" value="15.00" />
<input type="hidden" name="quantity_1" value="<%= Request.Form("add")%>" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="notify_url" value="http://10.5.0.43/catholicDirectory complete_order.aspx" />
<input type="hidden" name="no_shipping" value="2" />
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_cart_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" style="width:120px; height:26px;" target="_self"/></center>
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
What I need to know is how do I:
Why is my cart opening empty?
Get PayPal to redirect back to my website so I can mark the transaction as paid by storing maybe a PayPal transaction ID in my database I researched this and was able to direct them back if they click a link to return, but I don't want them to have to click anything. Research directed me to seller settings in my account but can't find them to set auto return url.
You're going to want to use PayPal's IPN listener. There is an IPN simulator which you can use to make sure it's hitting your site correctly.
https://developer.paypal.com/webapps/developer/applications/ipn_simulator
https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNSetup/
You'll need to setup 2 accounts within sandbox. A personal and a business. The business account is where you send transations. You can use the personal account to login and test payments.
As for redirecting back after payment, you can set this in both your return URL and inside PayPal
<input type="hidden" name="return" value="https://yoursite.com/payment-success">
You can set auto return by following the directions here: http://wemakewebsites.com/blog/how-to-get-paypal-to-auto-return-to-your-website-after-a-customer-payment
EDIT:
<form name="_xclick" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" >
<input id="element_1" name="amount" type="text" />
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="yourbusiness#email.com">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="item_name" value="Payment">
<input type="hidden" name="return" value="http://yourwebsite.com/payment-success">
<input type="hidden" name="rm" value="1">
<input type="image" src="http://yourwebsite.com/images/btn-donate.png" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<input type="hidden" name="notify_url" value="http://yourwebsite.com/includes/paypal_ipn.aspx" />
</form>
Once payment is made the user will head over to PayPal to complete the payment. As long as you have the notify_url set with a working listener PayPal will hit it. In that file is where you want to put a few more db collections. PayPal can send you back a bunch of information (https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNandPDTVariables/) depending on what data you are looking for. In the following example (https://github.com/paypal/ipn-code-samples/blob/master/paypal_ipn.vb) You'd want to add your db collection after line 35 where the user has completed payment:
If strResponse = "VERIFIED" Then
The idea was not to use an IPN listener (way more than I need), but rather to ask the customer how many books they wanted and add a single item to the PayPal cart: "# - 2015 Catholic Directory" where # is the quantity. The price for the book then becomes Quantity * $15. This way I can sell any quantity I want.
My database gets filled with customer information including quantity as a separate field when they fill out the order form and then that info gets sent on to PayPal to complete payment. Also I setup PayPal to auto return back to my site when the payment is complete and then mark the order as paid. This way I can develop reports for the office selling the books indicating who ordered how many books and if payment has been received.
Problem solved. The only thing I found difficult with the process was the fact that the sandbox environment does not have auto return like the live payment system does. I had to run a dummy sale for a penny and then refund the penny to verify the auto return was working.