Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / Oxygen Builder Temporary Cookies Modal JSON
Created September 10, 2024 22:22
Oxygen Builder Temporary Cookies Modal JSON
{"component":{"id":141,"name":"ct_div_block","options":{"ct_id":141,"ct_parent":100004,"selector":"div_block-141-109","original":{"width":"100","width-unit":"%"},"nicename":"Temporary Cookies Modal"},"depth":5,"children":[{"id":5,"name":"ct_code_block","options":{"ct_id":5,"ct_parent":141,"selector":"code_block-5-109","original":{"code-js":"document.addEventListener('DOMContentLoaded', function() {\n var cookieName = \"oxyModalCokkies\";\n var modals = document.querySelectorAll('.oxy-modal-cokkie');\n var closeButtons = [];\n\n if (localStorage.getItem(cookieName) && !sessionStorage.getItem(cookieName)) {\n document.cookie = cookieName + \"=; path=/; max-age=0\";\n localStorage.removeItem(cookieName);\n }\n\n if (document.cookie.split(';').some((item) => item.trim().startsWith(cookieName + '='))) {\n modals.forEach(modal => {\n if (modal && modal.parentElement) {\n modal.parentElement.remove();\n }\n });\n }\n\n modals.fo
@hssktm
hssktm / Maintenance Mode
Last active October 6, 2024 02:26
Maintenance Mode
function custom_maintenance_mode_setting() {
add_settings_section(
'maintenance_mode_section',
'Maintenance Mode',
null,
'general'
);
add_settings_field(
'maintenance_mode',
@hssktm
hssktm / EndPoint Api Template Oxygen Builder
Created October 5, 2024 19:07
EndPoint Api Template Oxygen Builder
add_action('rest_api_init', function () {
register_rest_route('api-oxygen/v1', '/oxygen-content/(?P<id>\d+)', array(
'methods' => 'GET',
'callback' => 'call_oxygen_content_api',
));
});
function call_oxygen_content_api($data) {
$post_id = $data['id'];
@hssktm
hssktm / Element Oxygen Builder Load More
Last active December 20, 2024 03:03
Element Oxygen Builder Load More
{"component":{"id":329,"name":"ct_div_block","options":{"ct_id":329,"ct_parent":3,"selector":"div_block-329-77","original":[],"nicename":"Element Load More"},"depth":4,"children":[{"id":330,"name":"ct_div_block","options":{"ct_id":330,"ct_parent":329,"selector":"div_block-330-77","original":{"custom-attributes":[{"name":"data-load-more-selector","value":"#id-and-class","pinned":true},{"name":"data-load-more","value":"click","pinned":true},{"name":"data-load-more-animation","value":"x-fadeZoomOut","pinned":true},{"name":"data-load-more-animation-initial","value":"false","pinned":true}],"custom-css":"","text-align":"left","flex-direction":"row","display":"flex","gap":"10","padding-top":"10","padding-bottom":"10","padding-left":"20","padding-right":"20","align-items":"center","border-radius":"100","background-color":"#5b2ae0","color":"#ffffff"},"nicename":"Load More","classes":["x-load-more"],"activeselector":false},"depth":5,"children":[{"id":331,"name":"ct_text_block","options":{"ct_id":331,"ct_parent":330,"se