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.
PayPal payment in Shopify is pre-built. So any custom PayPal payments built on top of default available payments will work independently. Hence, the order fulfillment will be missed.
You can also create orders manually in your Shopify admin to record orders that you've made outside of Shopify or to send your customers send invoices.
Please refer to this Link.
Thanks.