This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This code notifies Google Tag Manager when a wpForm is submitted | |
document.addEventListener("DOMContentLoaded", function() { | |
var elementsArray = document.querySelectorAll('[id^="wpforms-form-"]'); | |
elementsArray.forEach(function(elem) { | |
elem.addEventListener("submit", function(e) { | |
window.dataLayer = window.dataLayer || []; | |
window.dataLayer.push({ | |
event: "wpFormSubmit", | |
wpFormElement: event.target | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//AJAX ADD TO CART BUTTON | |
$product_id = 143; | |
if( !my_custom_cart_contains( $product_id ) ) { | |
?> | |
<button class="my-custom-add-to-cart-button" data-product-id="<?php echo $product_id; ?>">add to cart</button> | |
<?php | |
} else { | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function my_customize_rest_cors() { | |
remove_filter( 'rest_pre_serve_request', 'rest_send_cors_headers' ); | |
add_filter( 'rest_pre_serve_request', function( $value ) { | |
header( 'Access-Control-Allow-Origin: *' ); | |
header( 'Access-Control-Allow-Methods: GET' ); | |
header( 'Access-Control-Allow-Credentials: true' ); | |
header( 'Access-Control-Expose-Headers: Link', false ); |