Skip to content

Instantly share code, notes, and snippets.

View hamidrezayazdani's full-sized avatar
🤕

Hamid Reza Yazdani hamidrezayazdani

🤕
View GitHub Profile
@hamidrezayazdani
hamidrezayazdani / digits-wc-compatibility.php
Created October 12, 2021 23:42
هماهنگی افزونه دیجیتس با محصولات دانلودی ووکامرس
<?php
/**
* Sync wc with DIGITS plugin
*/
function ywp_sync_digits_with_wc( $customer_id, $new_customer_data, $password_generated ) {
$user = get_user_by( 'id', $customer_id );
if ( $user && property_exists( $user, 'user_email' ) && empty( $user->user_email ) ) {
$fake_mail = sprintf(
<?php
function wpp_woodmart_ajax_search_compatibility( $args ) {
if ( function_exists( 'fix_arabic' ) ) {
$args['s'] = fix_arabic( $args['s'] );
}
return $args;
}
@hamidrezayazdani
hamidrezayazdani / show-variation-description-in-single-product.php
Last active October 8, 2021 17:42
نمایش توضیحات آیتم متغیر انتخاب شده محصول متغیر در صفحه محصول ووکامرس
<?php
function ywp_show_variation_description() { ?>
<div id="ywp-var-desc"></div>
<script>
jQuery(function($){
$('form.variations_form').on('show_variation', function (event, data) {
$('#ywp-var-desc').html(data.variation_description);
});
})
<?php
/**
* Change min qty to area
*/
function ywp_set_min_qty_decimal( $val ) {
return 0.1;
}
add_filter('woocommerce_quantity_input_min', 'ywp_set_min_qty_decimal');
<?php
function wpp_replace_arabic_chars_in_search_term( $request_vars ) {
if ( function_exists( 'fix_arabic' ) && ! empty( $request_vars['s'] ) ) {
$request_vars['s'] = fix_arabic( $request_vars['s'] );
}
return $request_vars;
}
@hamidrezayazdani
hamidrezayazdani / wc-latest-modified-products-shortcode.php
Created September 28, 2021 16:47
کد کوتاه نمایش محصولات بر اساس تاریخ آخرین ویرایش در ووکامرس
<?php
function ywp_date_modified_wc_product_shortcode( $args, $atts ){
$atts = shortcode_atts(
array(
'orderby' => 'date',
'interval' => '20',
), $atts, 'bartag'
);
if ( 'date_modified' === esc_attr( $atts['orderby'] ) ) {
@hamidrezayazdani
hamidrezayazdani / get-order-shipping-method-details.php
Created September 20, 2021 20:38
دریافت اطلاعات «روش‌های ارسال» سفارش خاص
<?php
$order = wc_get_order( $order_id );
$order_shipping_methods = $order->get_items( 'shipping' );
foreach ( order_shipping_methods as $item_id => $item ) {
$shipping_method_instance_id = $item->get_instance_id();
$shipping_method_id = $item->get_method_id();
$shipping_method_title = $item->get_method_title();
$order_item_name = $item->get_name();
@hamidrezayazdani
hamidrezayazdani / add-custom-bulk-action-to-wc-orders.php
Created September 18, 2021 09:21
افزودن «کارهای دسته جمعی» به سفارشات ووکامرس
<?php
/**
* Add packaging option to order bulk actions
*/
function ywp_add_packaging_to_bulk_actions( $actions ) {
$actions['mark_packaging'] = 'تغییر وضعیت به بسته‌بندی';
return $actions;
}
@hamidrezayazdani
hamidrezayazdani / convert-all-price-from-Rial-to-Toman.sql
Last active September 1, 2021 13:43
تبدیل قیمت کلیه محصولات ووکامرس از ریال به تومان
-- توجه: حتما قبل از اجرای این کد، از دیتابیس نسخۀ پشتیبان تهیه کنید --
-- وارد فضای هاست خود شده و PHPMyAdmin را باز کرده و کد زیر را در بخش SQL اجرا کنید. --
-- تبدیل قیمت همه محصولات به تومان --
UPDATE
wp_postmeta
SET
<?php
/**
* Add custom endpoint to the My Account menu
*
* @param array $items
*
* @return array
*/
function ywp_account_menu_custom_item( $items ) {
$logout = $items['customer-logout'];