Skip to content

Commit

Permalink
hide button on out of stock; add product variation handling
Browse files Browse the repository at this point in the history
  • Loading branch information
netzkollektiv committed Dec 5, 2022
1 parent dfe003a commit 583ff6e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 34 deletions.
52 changes: 26 additions & 26 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,22 @@ jQuery(function($){
onHydrated(selector, function(selector) {
$(selector).submit(function(e){
var form = $(this).closest('.summary').find('form.cart');
if (form.length > 0 && form.find('button[name="add-to-cart"]')) {
form.append('<input type="hidden" name="easycredit-express" value="1" />')
.find('button[name="add-to-cart"]')
.click();
}
if (form.length > 0) {

var addToCartButton = form.find('button[name="add-to-cart"], button.single_add_to_cart_button');
if (addToCartButton.length > 0) {
form.append('<input type="hidden" name="easycredit-express" value="1" />')
.find(addToCartButton)
.click();
}
}
if ($(this).closest('.wc-proceed-to-checkout').length > 0) {
window.location.href = '/easycredit/express';
}
});
$('form.variations_form').on('show_variation', function(event, data, purchasable) {
(!purchasable) ? $(selector).hide() : $(selector).show();
});
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@ public function add_button_at_product() {
$product = new WC_Product( $post->ID );
$amount = $product->get_price();

if ($product->get_price() > 199 && $product->get_price() <= 10000) {
if ($product->is_in_stock() && $product->get_price() > 199 && $product->get_price() <= 10000) {
echo '<easycredit-express-button
webshop-id="'.$this->gateway->get_option('api_key').'"
amount="'.$product->get_price().'"
'.$attributes.'
></easycredit-express-button>';
}
}
Expand Down

0 comments on commit 583ff6e

Please sign in to comment.