Skip to content

Instantly share code, notes, and snippets.

View MarkKevin08's full-sized avatar

MarkKevin08

View GitHub Profile
@MarkKevin08
MarkKevin08 / function.php
Created January 11, 2024 12:55
XT Quick View - Use dynamic product ID - Extend shortcode
function xt_qv_shortcode_extension() {
global $product;
$id = $product->get_id();
return do_shortcode( '[xt_wooqv_trigger id="' . $id . '"]');
}
add_shortcode( 'my_new_shortcode', 'xt_qv_shortcode_extension' );
@MarkKevin08
MarkKevin08 / Frequently Bought Together snippet
Last active January 5, 2024 06:35
If -0%, then hide this div - Frequently Bought Together
const divs = document.getElementsByClassName('product-bundle__discount-label');
for (let x = 0; x < divs.length; x++) {
const div = divs[x];
const content = div.textContent.trim();
if (content == '0%' || content == '-0%') {
div.style.display = 'none';
}
}
@MarkKevin08
MarkKevin08 / WPUM Content Restriction Redirection sample
Created January 2, 2024 07:11
WPUM Content Restriction Redirection sample
function restrict_access_for_specific_page() {
// Specify the page ID where you want to apply the restriction
$restricted_page_id = 123; // Replace 123 with the actual page ID
// Check if the current page is the restricted page
if (is_page($restricted_page_id)) {
// Specify the URL that users must come from to access the page
$allowed_url = 'https://example.com/allowed-url';
// Get the referring URL
<!-- Attributes -->
<?php do_action( 'wcv_before_attributes_tab', $object_id ); ?>
<div class="wcv_product_attributes tabs-content" id="attributes">
<div class="attributes-validation-error"></div>
<?php WCVendors_Pro_Product_Form::product_attributes( $object_id ); ?>
@MarkKevin08
MarkKevin08 / checkrememberme
Last active December 6, 2023 09:23
Auto check WPUM login page's "remember me" field
add_filter( 'login_form_fields', 'remember_me_checked' );
function remember_me_checked($fields) {
if ( isset( $fields['login']['remember'] ) ) {
?>
<script type="text/javascript">
function checkit() {
document.getElementById('remember').checked = true;
}
@MarkKevin08
MarkKevin08 / AG Webhook Delay Snippet
Last active December 4, 2023 11:56
Webhook Delay Snippet
define('ag_webhook_delay', TRUE);
@MarkKevin08
MarkKevin08 / wpum_recaptcha_score_threshold.php
Created July 19, 2023 08:44
WPUM - Change the reCaptcha v3 required score
add_filter( 'wpum_recaptcha_score_threshold', 'my_recaptcha_score' );
function my_recaptcha_score( $score ) {
/*
* Return a score between 1 and 0.1.
* A lower score will let through more results.
*/
return 0.3;
}
@MarkKevin08
MarkKevin08 / function.php
Created June 9, 2023 03:37
Open booking resources editor in new tab
function wcv_add_target_blank_for_button() {
?>
<script>
jQuery(document).ready(function ($) {
let $manageResource = $('.button.button-primary.add_resource').next();
if ($manageResource.length) {
$manageResource.attr('target', '_blank');
}
});
</script>
@MarkKevin08
MarkKevin08 / function.php
Created June 8, 2023 02:49
WC Vendors - Prevent vendor edit booking start date and end date
/**
* Prevent vendor edit booking start date and end date
*/
function wcv_prevent_vendor_edit_booking_start_date_and_end_date() {
$pagename = get_query_var( 'pagename' );
$object = get_query_var( 'object' );
$action = get_query_var( 'action' );
if ( ! is_user_logged_in() ) {
// Add 16% VAT to vendor commission
add_filter( 'wcv_process_commission', 'my_wcv_commission_rate', 10, 5 );
add_filter( 'wcv_commission_rate', 'my_wcv_commission_rate', 10, 5 );
function my_wcv_commission_rate( $commission, $product_id, $product_price, $order, $qty ) {
$vat_fee = 0.16;
$marketplace_split = $product_price - $commission;
$vat = $marketplace_split * $vat_fee;
$commission -= $vat;