Skip to content

Instantly share code, notes, and snippets.

@hssktm
hssktm / Element QuickView for Oxygen Builder
Last active September 25, 2024 03:07
Element QuickView for Oxygen Builder
/*Paste this code into a plugin like Code Snippets or the one of your choice */
function oxy_call_id_quickview() {
if (isset($_GET['quickterm']) && !empty($_GET['quickterm'])) {
return sanitize_text_field($_GET['quickterm']);
} else {
$args = array(
'post_type' => 'product',
'posts_per_page' => 1,
'orderby' => 'date',
'order' => 'ASC'
@hssktm
hssktm / Wishlist Oygen Builder
Last active March 13, 2025 08:13
Contains JSON and Code to paste into code plugin
//JSON OXYGEN BUILDER
{"component":{"id":216,"name":"ct_div_block","options":{"ct_id":216,"ct_parent":100004,"selector":"div_block-216-53","original":{"padding-bottom":"0"},"nicename":"Wishlist Elements","activeselector":false},"depth":5,"children":[{"id":217,"name":"ct_code_block","options":{"ct_id":217,"ct_parent":216,"selector":"code_block-217-53","nicename":"Code Wishlist Paste Global","activeselector":false,"original":{"code-php":"<script>\n\ndocument.addEventListener('DOMContentLoaded', function() {\n if (window.angular) return;\n assignButtonEvents();\n\n function assignButtonEvents() {\n const wishlistButtons = document.querySelectorAll('.oxy-add-to-wishlist, .oxy-remove-from-wishlist');\n\n wishlistButtons.forEach(button => {\n button.removeEventListener('click', handleWishlistButtonClick);\n button.addEventListener('click', handleWishlistButtonClick);\n });\n }\n\n function handleWishlistButtonClick(event) {\n const button = event.cur
@hssktm
hssktm / Buttons Woocommerce ADD
Last active June 22, 2024 01:59
Code JSON Oxygen Builder
{"component":{"id":541,"name":"ct_div_block","options":{"ct_id":541,"ct_parent":538,"selector":"div_block-541-29","original":[],"nicename":"Buttons Woocommerce"},"depth":4,"children":[{"id":669,"name":"ct_code_block","options":{"ct_id":669,"ct_parent":541,"selector":"code_block-669-29","original":{"code-php":"<!---->","code-js":"jQuery(document).ready(function() {\n if( window.angular ) return;\n jQuery(document.body).on('added_to_cart', function(event, fragments, cart_hash, button) {\n var product_id = jQuery(button).data('product_id');\n jQuery('[data-product_id=\"' + product_id + '\"]').closest('.oxy-woo-button').parent().addClass('view-cart added');\n });\n jQuery('.oxy-woo-button').on('click', function() {\n var product_id = jQuery(this).data('product_id');\n });\n\n ///QTY\njQuery(document).ready(function() {\n jQuery('.oxy-woo-buttons-add').on('click', '.oxy-woo-qty-min, .oxy-woo-qty-plus', function() {\n var $input = jQuery(this).closest('.oxy-woo-buttons
@hssktm
hssktm / Element Count UP scroll JSON
Last active May 11, 2024 23:42
Element Count UP scroll
{"component":{"id":2,"name":"ct_section","options":{"ct_id":2,"ct_parent":0,"selector":"section-2-57","original":[],"nicename":"Element Count Section"},"depth":1,"children":[{"id":57,"name":"ct_div_block","options":{"ct_id":57,"ct_parent":2,"selector":"div_block-57-57","original":[],"nicename":"Element Count","classes":["full-width","is-center"],"activeselector":"is-center"},"depth":2,"children":[{"id":58,"name":"ct_code_block","options":{"ct_id":58,"ct_parent":57,"selector":"code_block-58-57","original":{"code-js":"function counter() {\n\n \tif( window.angular ) return;\n \n var xCountElements = document.querySelectorAll('.x-count');\n xCountElements.forEach(function(element) {\n if (element.classList.contains('x-start')) {\n var elementTop = element.offsetTop;\n var elementHeight = element.offsetHeight;\n var elementBottom = elementTop + elementHeight;\n var viewportTop = window.pageYOffset || document.documentElement.scrollTop;\n var vie
@hssktm
hssktm / Element Sale Countdown
Last active September 26, 2024 22:04
JSON OXYGEN
{"component":{"id":500,"name":"ct_div_block","options":{"ct_id":500,"ct_parent":100004,"selector":"div_block-500-72","original":[],"nicename":"Element Countdown"},"depth":5,"children":[{"id":520,"name":"ct_code_block","options":{"ct_id":520,"ct_parent":500,"selector":"code_block-520-72","original":{"code-js":"function updateTimers() {\n if (window.angular) return;\n\n var now = new Date();\n var containers = document.querySelectorAll(\".x-count\");\n\n containers.forEach(function(container) {\n var future = new Date(\n container.getAttribute(\"data-count-year\"),\n parseInt(container.getAttribute(\"data-count-mo\")) - 1,\n parseInt(container.getAttribute(\"data-count-day\")) + 0\n );\n\n var diff = future - now;\n\n var days = Math.floor(diff / (1000 * 60 * 60 * 24));\n var hours = Math.floor(diff / (1000 * 60 * 60)) % 24;\n var mins = Math.floor(diff / (1000 * 60)) % 60;\n var secs = Math.floor(diff / 1000) % 60;\n\n var daysElement = container.querySelector(\".x-co
@hssktm
hssktm / Woo Fields
Last active October 28, 2024 11:41
Extract different woocommerce fields easily
function woo_field($property) {
$date_format = 'd - M - Y'; // Format Date
$info = null;
if (!in_array($property, ['cart_product_ids', 'cart_total_items', 'cart_total_price'])) {
global $product;
if (!$product) {
$product = wc_get_product(get_the_ID());
}
@hssktm
hssktm / Custom Search
Created April 1, 2024 23:55
Code JSON
{"component":{"id":462,"name":"ct_section","options":{"ct_id":462,"ct_parent":100002,"selector":"section-462-175","original":{"custom-attributes":[[]],"gap":"40"},"nicename":"Section (#462)","activeselector":""},"depth":2,"children":[{"id":463,"name":"ct_div_block","options":{"ct_id":463,"ct_parent":462,"selector":"div_block-463-175","original":{},"nicename":"Pagination A"},"depth":3,"children":[{"id":464,"name":"ct_div_block","options":{"ct_id":464,"ct_parent":463,"selector":"div_block-464-175","original":{"conditionspreview":"2","globalConditionsResult":true},"nicename":"CLASS COPY DELETE","classes":["x-pagination__numbers"],"activeselector":"x-pagination__numbers"},"depth":4,"children":[{"id":465,"name":"ct_text_block","options":{"ct_id":465,"ct_parent":464,"selector":"text_block-465-175","original":[],"nicename":"Text (#275)","classes":["x-pagination__number","x-pagination__number--current"],"activeselector":"x-pagination__number","ct_content":"1"},"depth":5},{"id":466,"name":"ct_text_block","options":{"c
@hssktm
hssktm / gist:2f5e84b85ed6e3e14359de3b8e466715
Last active December 9, 2023 10:30
Gallery ACF + Repeater Oxygen Builder
//*******Lightbox***********/
function load_glightbox_scripts() {
if (!is_admin()) {
wp_enqueue_style('glightbox-css', 'https://cdn.jsdelivr.net/npm/glightbox/dist/css/glightbox.min.css');
wp_enqueue_script('glightbox-js', 'https://cdn.jsdelivr.net/gh/mcstudios/glightbox/dist/js/glightbox.min.js', array('jquery'), null, true);
}
}
add_action('wp_enqueue_scripts', 'load_glightbox_scripts');
function load_splide_scripts() {
wp_register_script('splide-js', 'https://cdn.jsdelivr.net/npm/@splidejs/[email protected]/dist/js/splide.min.js', array(), '4.1.4', true);
wp_register_style('splide-css', 'https://cdn.jsdelivr.net/npm/@splidejs/[email protected]/dist/css/splide.min.css', array(), '4.1.4');
if (is_front_page()) {
wp_enqueue_script('splide-js');
wp_enqueue_style('splide-css');
}
}
add_action('wp_enqueue_scripts', 'load_splide_scripts');