Shopify themes, liquid, logos, and UX
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hello,
I am trying to implement the Express checkout Paypal button on a single product page. For the moment I am using the dynamic checkout button which is working for all available payment options.
I managed so far to paste HTML code (generated by Paypal button manager) in
product-template.liquid
and button was visible on a single product page.
When I do testing, the button redirects me to PayPal but the price is not taken from Shopify, in other words, you get the blank form to introduce the amount which you want to pay by PayPal.
My question is did I miss something, and do I have to paste some additional PayPal script that can be found on their developer site or just I will have to write a custom script (javascript) that can resolve
this issue. When I make the Express PayPal button working, I will switch off the dynamic checkout button and leave only the Expres Check PayPal button on the single product page.
Hello,
This is updated how far i arrived.
I added a second custom Paypal button on my single product page in order to turn off the dynamic payment button for my users.
I successfully did that and the button works and payment in Paypal is received.
However, I have a problem which is that the order made by the customer is not registered in the admin panel dashboard (Shopify) so my logistic
can sees it too. My code in
product-template.liquid
goes like this
button code
<div class="product-single__add js-product-buttons{% unless product.available %} product-single__add--sold{% endunless %}">
<button type="submit" name="add" class="c-btn c-btn--full c-btn--plus c-btn--{% if section.settings.enable_payment_button %}light{% else %}primary{% endif %} product-single__add-btn js-product-add">
<span class="js-product-add-text">{{ 'products.product.add_to_cart' | t }}</span>
</button>
{% if section.settings.enable_payment_button %}
{{ form | payment_button }}
{% endif %}
</div>
{% endform %}
<!-- Set up a container element for the button -->
<!--<div id="paypal-button-container"></div> -->
</div>
{% endform %}
<!-- Set up a container element for the button -->
<div id="paypal-button-container"></div>
and my javascript goes like this
<script>
// Render the PayPal button into #paypal-button-container
paypal.Buttons({
// Set up the transaction
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: {{product.price | dividedby: 100.0 }}
}
}]
});
},
// Finalize the transaction
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
// Show a success message to the buyer
alert('Transaction completed by ' + details.payer.name.given_name + '!');
});
}
}).render('#paypal-button-container');
</script>
Since that I am new to Shopify is there is an event or function which I should implement into existing javascript.