Home › Forums › WoodMart support forum › Side Menu Suggestion
Side Menu Suggestion
- This topic has 7 replies, 2 voices, and was last updated 2 years, 6 months ago by Luke Nielsen.
-
AuthorPosts
-
June 7, 2022 at 4:13 pm #381700
iamfahrigParticipantJune 7, 2022 at 4:57 pm #381714
Luke NielsenKeymasterHello,
Thanks for reaching us, we really appreciate your feedback! We are always trying to improve our product to provide you with a better experience. I will be sure to pass your suggestion onto our team for their consideration.
If you have any questions or wish to learn more about our theme, do reach out to our customer service team at any time
Kind Regards
July 3, 2022 at 10:28 am #388157
iamfahrigParticipantAdd the following Custom CSS to the Public Custom CSS field under Theme Settings >> Custom CSS.
———————————————————————————————-//Kupon Kodu Otomatik Açılır Hale Getirme Kodu// .woocommerce-checkout .checkout_coupon.woocommerce-form-coupon { display: block !important; }
———————————————————————————————-
In the functions.php, add the following code:
———————————————————————————————-// Remove default coupon field remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 ); // Add a custom coupon field before checkout payment section add_action( 'woocommerce_review_order_before_payment', 'woocommerce_checkout_coupon_form_custom' ); function woocommerce_checkout_coupon_form_custom() { echo '<div class="coupon-form" style="margin-bottom:20px;"> <p>' . __("İNDİRİM KODU GİR") . '</p> <p class="form-row form-row-first woocommerce-validated"> <input type="text" name="coupon_code" class="input-text" placeholder="' . __("Kodunuzu Giriniz") . '" id="coupon_code" value=""> </p> <p class="form-row form-row-last"> <button type="button" class="button" name="apply_coupon" value="' . __("Apply coupon") . '">' . __("UYGULA") . '</button> </p> <div class="clear"></div> </div>'; } // jQuery - Send Ajax request add_action( 'wp_footer', 'custom_checkout_jquery_script' ); function custom_checkout_jquery_script() { if ( is_checkout() && ! is_wc_endpoint_url() ) : ?> <script type="text/javascript"> jQuery( function($){ if (typeof wc_checkout_params === 'undefined') return false; var couponCode = ''; $('input[name="coupon_code"]').on( 'input change', function(){ couponCode = $(this).val(); }); $('button[name="apply_coupon"]').on( 'click', function(){ $.ajax({ type: 'POST', url: wc_checkout_params.ajax_url, data: { 'action': 'apply_checkout_coupon', 'coupon_code': couponCode, }, success: function (response) { $(document.body).trigger("update_checkout"); // Refresh checkout $('.woocommerce-error,.woocommerce-message').remove(); // Remove other notices $('input[name="coupon_code"]').val(''); // Empty coupon code input field $('form.checkout').before(response); // Display notices // console.log(response); // Uncomment for testing } }); }); }); </script> <?php endif; } // Ajax receiver function add_action( 'wp_ajax_apply_checkout_coupon', 'apply_checkout_coupon_ajax_receiver' ); add_action( 'wp_ajax_nopriv_apply_checkout_coupon', 'apply_checkout_coupon_ajax_receiver' ); function apply_checkout_coupon_ajax_receiver() { if ( isset($_POST['coupon_code']) && ! empty($_POST['coupon_code']) ) { WC()->cart->add_discount( wc_format_coupon_code( wp_unslash( $_POST['coupon_code'] ) ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized } else { wc_add_notice( WC_Coupon::get_generic_coupon_error( WC_Coupon::E_WC_COUPON_PLEASE_ENTER ), 'error' ); } wc_print_notices(); wp_die(); }
Attachments:
You must be logged in to view attached files.July 4, 2022 at 10:05 am #388360
Luke NielsenKeymasterHello,
Please, describe the above code, is that your problem or suggestion?
Looking forward to hearing back from you!
Kind Regards
July 4, 2022 at 2:43 pm #388451
iamfahrigParticipantSuggestion Move coupon form before payment section in WooCommerce checkout
Move coupon form before payment section in WooCommerce checkout
———————————————————————————————-
In the functions.php, add the following code:
———————————————————————————————-// Just hide default woocommerce coupon field add_action( 'woocommerce_before_checkout_form', 'hide_checkout_coupon_form', 5 ); function hide_checkout_coupon_form() { echo '<style>.woocommerce-form-coupon-toggle {display:none;}</style>'; } // Add a custom coupon field before checkout payment section add_action( 'woocommerce_review_order_before_payment', 'woocommerce_checkout_coupon_form_custom' ); function woocommerce_checkout_coupon_form_custom() { echo '<div class="checkout-coupon-toggle"><div class="woocommerce-info">' . sprintf( __("Have a coupon? %s"), '<a href="#">' . __("Click here to enter your code") . '</a>' ) . '</div></div>'; echo '<div class="coupon-form" style="margin-bottom:20px;" style="display:none !important;"> <p>' . __("If you have a coupon code, please apply it below.") . '</p> <p class="form-row form-row-first woocommerce-validated"> <input type="text" name="coupon_code" class="input-text" placeholder="' . __("Coupon code") . '" id="coupon_code" value=""> </p> <p class="form-row form-row-last"> <button type="button" class="button" name="apply_coupon" value="' . __("Apply coupon") . '">' . __("Apply coupon") . '</button> </p> <div class="clear"></div> </div>'; } // jQuery code add_action( 'wp_footer', 'custom_checkout_jquery_script' ); function custom_checkout_jquery_script() { if ( is_checkout() && ! is_wc_endpoint_url() ) : ?> <script type="text/javascript"> jQuery( function($){ $('.coupon-form').css("display", "none"); // Be sure coupon field is hidden // Show or Hide coupon field $('.checkout-coupon-toggle .show-coupon').on( 'click', function(e){ $('.coupon-form').toggle(200); e.preventDefault(); }) // Copy the inputed coupon code to WooCommerce hidden default coupon field $('.coupon-form input[name="coupon_code"]').on( 'input change', function(){ $('form.checkout_coupon input[name="coupon_code"]').val($(this).val()); // console.log($(this).val()); // Uncomment for testing }); // On button click, submit WooCommerce hidden default coupon form $('.coupon-form button[name="apply_coupon"]').on( 'click', function(){ $('form.checkout_coupon').submit(); // console.log('click: submit form'); // Uncomment for testing }); }); </script> <?php endif; }
- This reply was modified 2 years, 6 months ago by iamfahrig.
July 4, 2022 at 5:02 pm #388517
Luke NielsenKeymasterHello,
Thank you for your suggestions, if you have more ideas, please describe them in this https://xtemos.com/forums/topic/features-requests-2/ topic, it’s a special topic for the customer’s suggestions.
Have a good day!
Kind Regards
July 22, 2022 at 5:02 pm #392929
iamfahrigParticipantYou can close the topic.
July 22, 2022 at 5:16 pm #392935
Luke NielsenKeymasterHello,
Don’t hesitate to reach out if you have any more questions or concerns. We’re thankful that you took the time to share your concerns with us.
Wish you all the best.
Kind Regards
-
AuthorPosts
The topic ‘Side Menu Suggestion’ is closed to new replies.
- You must be logged in to create new topics. Login / Register