🎄 یک برنامه نویس تنبل – Telegram
🎄 یک برنامه نویس تنبل
2K subscribers
1.51K photos
280 videos
37 files
1.88K links
کانال یک برنامه نویس تنبل

🔥لینوکس
🔥برنامه نویسی فرانت‌اند
🔥برنامه نویسی بک‌اند
🔥اخبار تکنولوژی و...

ارتباط با مدیریت :

@CoderNap

اسپانسر هاست سایت راییوم توسط پوینا

https://rayium.ir

@poinair
Download Telegram
🔶 کد توابع مخفی کردن قیمت محصولات ناموجود در ووکامرس

روش اول :

function mrcode_remove_outofstock_prices( $price, $product ) {
if ( ! $product->is_in_stock() ) {
$price = '';
}
return $price;
}

add_filter( 'woocommerce_variable_sale_price_html', 'mrcode_remove_outofstock_prices', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'mrcode_remove_outofstock_prices', 10, 2 );
add_filter( 'woocommerce_get_price_html', 'mrcode_remove_outofstock_prices', 10, 2 );


روش دوم :

<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

global $post, $product;
?>
<div itemprop="offers" itemscope itemtype="http://schema.org/Offer">

<p class="price"> <?php
$stockamount = $product->get_stock_quantity();
$price = $product->get_price_html();
$pricelabel = "تماس بگیرید";
if($stockamount == 0)
{
echo $pricelabel;
}
else
{
echo $price;
};
?>
</p>

<meta itemprop="price" content="<?php echo $product->get_price(); ?>" />
<meta itemprop="priceCurrency" content="<?php echo get_woocommerce_currency(); ?>" />
<link itemprop="availability" href="http://schema.org/<?php echo $product->is_in_stock() ? 'InStock' : 'OutOfStock'; ?>" />

</div>


روش سوم :

.outofstock .price{display:none}
.outofstock .amount{display:none}


@TheRaymondDev
👍1
🔶 رفع مشکل کار نکردن صفحات لاراول – لایووایر

لایو وایر یک چارچوب فول استک برای لاراول است که به راحتی می توانید صفحات را داینامیک کنید. در این مقاله می خواهیم مشکل کار نکردن صفحات لاراول – لایو وایر بپردازیم.

همین طور می ببینید در انتهای URL صفحه علامت سوال (?) نمایش می دهد که نشان از کار نکردن صفحات لاراول – لایو وایر است که به این شکل است:

http://127.0.0.1:8000/users/create?


صفحات سمت کاربر (فرانت اند) نمایش داده می شوند و مشکلی نداره اما هیچ داده ای ثبت و نمایش نمی دهد و با کنترلر ارتباط برقرار نمی کند.

اگر فراخوانی صفحات blade به شکل زیر باشد, کار نمی کند چرا که این مدل فراخوانی برای لایو وایر نیست.

@extends('layouts.app')
@section('content')
تست
@endsection


لایو وایر متد فراخوانی را در تابع رندر انجام می دهد و از این طریق صفحات را بارگزاری می کند و با کنترلر ارتباط برقرار می کند.

public function render()
{
return view('livewire.support.users.create')
->extends('layouts.app')
->section('content');

}


@TheRaymondDev
👍2
🖥 5 کانال یوتیوب برای دوستانی که در حال یادگیری زبان انگلیسی هستند.

1️⃣ کانال Rachel's English:

👨‍💻این کانال برای دانش آموزان سطح متوسط تا پیشرفته هست که علاقه مند به بهبود تلفظ و لهجه انگلیسی آمریکایی هستن.

2️⃣ کانال Accent's way English with Hadar :

👨‍💻یک تدریس جالب و سرگرم کننده برای بهبود تلفظ.

3️⃣ کانال English with jennifer: 

👨‍💻برای زبان آموزان سطح مبتدی تا متوسط، ارائه ساده مطالب و تمرکز ویژه بر تلفظ.

4️⃣ کانال mmmEnglish :

👨‍💻دستور زبان تلفظ مهارتهای مکالمه و واژگان نکات و ترفند های مفید برای بهبود مهارت هارو ارتباطی در زبان انگلیسی.

5️⃣ کانال Papa Teach me :

👨‍💻منبع عالی برای هر کسی که به بهبود مهارتهای زبان انگلیسی بریتانیایی علاقه داره.

@TheRaymondDev
👍3
🔶 به المنتور کاران میگن برنامه نویس وردپرس 🤦‍♂️😂

@TheRaymondDev
😁4🤯4
🔶 نمایش برچسب جدید در محصولات ووکامرس

عملکرد این برچسب اینکه هر محصولی که منتشر شود برچسب جدید بهش چسبانده میشه و 30 روز برچسب آن می ماند و بعد از آن خودکار حذف می شود.

function themefars_new_badge_shop_page() {
global $product;
$newness_days = 30;
$created = strtotime( $product->get_date_created() );
if ( ( time() - ( 60 * 60 * 24 * $newness_days ) ) < $created ) {
echo '<span class="itsnew onsale">' . esc_html__( 'جدید', 'woocommerce' ) . '</span>';
}
}


@TheRaymondDev
🔶 کد ویرایش فیلدهای اضافی پرداخت ووکامرس

add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
add_filter( 'woocommerce_billing_fields' , 'custom_override_billing_fields' );
add_filter( 'woocommerce_shipping_fields' , 'custom_override_shipping_fields' );

function custom_override_checkout_fields( $fields ) {
unset($fields['billing']['billing_state']);
unset($fields['billing']['billing_country']);
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_address_1']);
unset($fields['billing']['billing_address_2']);
unset($fields['billing']['billing_postcode']);
unset($fields['billing']['billing_city']);
unset($fields['shipping']['shipping_state']);
unset($fields['shipping']['shipping_country']);
unset($fields['shipping']['shipping_company']);
unset($fields['shipping']['shipping_address_1']);
unset($fields['shipping']['shipping_address_2']);
unset($fields['shipping']['shipping_postcode']);
unset($fields['shipping']['shipping_city']);
return $fields;
}
function custom_override_billing_fields( $fields ) {
unset($fields['billing_state']);
unset($fields['billing_country']);
unset($fields['billing_company']);
unset($fields['billing_address_1']);
unset($fields['billing_address_2']);
unset($fields['billing_postcode']);
unset($fields['billing_city']);
return $fields;
}
function custom_override_shipping_fields( $fields ) {
unset($fields['shipping_state']);
unset($fields['shipping_country']);
unset($fields['shipping_company']);
unset($fields['shipping_address_1']);
unset($fields['shipping_address_2']);
unset($fields['shipping_postcode']);
unset($fields['shipping_city']);
return $fields;
}


@TheRaymondDev
🔶 کد تابع نمایش برچسب محصولات تخفیف خورده ووکامرس

add_filter( 'woocommerce_sale_flash', 'add_percentage_to_sale_badge', 20, 3 );
function add_percentage_to_sale_badge( $html, $post, $product ) {

if( $product->is_type('variable')){
$percentages = array();

// Get all variation prices
$prices = $product->get_variation_prices();

// Loop through variation prices
foreach( $prices['price'] as $key => $price ){
// Only on sale variations
if( $prices['regular_price'][$key] !== $price ){
// Calculate and set in the array the percentage for each variation on sale
$percentages[] = round( 100 - ( floatval($prices['sale_price'][$key]) / floatval($prices['regular_price'][$key]) * 100 ) );
}
}
// We keep the highest value
$percentage = max($percentages) . '%';

} elseif( $product->is_type('grouped') ){
$percentages = array();

// Get all variation prices
$children_ids = $product->get_children();

// Loop through variation prices
foreach( $children_ids as $child_id ){
$child_product = wc_get_product($child_id);

$regular_price = (float) $child_product->get_regular_price();
$sale_price = (float) $child_product->get_sale_price();

if ( $sale_price != 0 || ! empty($sale_price) ) {
// Calculate and set in the array the percentage for each child on sale
$percentages[] = round(100 - ($sale_price / $regular_price * 100));
}
}
// We keep the highest value
$percentage = max($percentages) . '%';

} else {
$regular_price = (float) $product->get_regular_price();
$sale_price = (float) $product->get_sale_price();

if ( $sale_price != 0 || ! empty($sale_price) ) {
$percentage = round(100 - ($sale_price / $regular_price * 100)) . '%';
} else {
return $html;
}
}
return '<span class="onsale badge bg-danger fs-6 rounded-5"><i class="fa-light fa-badge-percent"></i> ' . $percentage . ' ' . esc_html__( 'تخفیف', 'woocommerce' ) . ' </span>';
}

نمایش برچسب تخفیف :

<?php echo apply_filters( 'woocommerce_sale_flash', '<span class="onsale">' . esc_html__( '', 'woocommerce' ) . '</span>', $post, $product ); ?>


@TheRaymondDev
🔥1
🔶 سعی دارم کد نویسی قالب رو زودتر تمام کنم و در سایت خودم برای فروش قرار میدم.
بعد از اتمام آن ضبط دوره ووکامرس آغاز میشه...

@TheRaymondDev
1
index.html
6.6 KB
🔶 آیکون واحد پولی ایران (تومان) با پسوند SVG

@TheRaymondDev
2
🔶 پیش نمایش آیکون تومان ایران

@TheRaymondDev
🔶 متاسفانه اسم دامنه سایت به نام ارکیده به خاطر سراسری بودن اسم در گوگل قابل شناسایی نیست.
مجبورم یه اسم جدید براش تعریف و دامنه ثبت کنم. 😐

@TheRaymondDev
😁1
🔶 کد تابع نمایش برچسب های پست ووکامرس

<?php
$product_tags = get_terms('product_tag');
foreach ($product_tags as $tag) {
echo '<a href="' . esc_url(get_term_link($tag)) . '">' . esc_html($tag->name) . '</a>';
}
?>

@TheRaymondDev
🔶 محدودیت های شدید اینترنتی و اجتماعی ایران باعث مهاجرت گسترده نخبگان ایرانی می شود.
فرقی نمی کند چه رشته ای باشد و این محدودیت ها باعث میشه که جلوی هر پیشرفتی بگیرد و نخبه به چه امیدی در این کشور بماند.

@TheRaymondDev
👍2
سلام 🙋‍♂️

خب دامنه جدید ثبت کردم
با اینکه اسمم رایموند هست و آخر یوم ium داره که خلاصه اش کردم rayium

خب دامنه شد rayium.ir
به فارسی میشه راییوم

@TheRaymondDev
🔶 طبق صحبت هایی که با کانال پوینا کردم می گوید که کش ردیس در هاست های اشتراکی باگ دارد و اما در سرور های اختصاصی چنین مشکلی ندارد.
می توانید کش ردیس در سرور اختصاصی استفاده کنید.

@TheRaymondDev
1
🔶 کد تابع سازگار کردن فرم های صفحه سفارش ووکامرس به بوت استرپ 5

add_filter('woocommerce_checkout_fields', 'addBootstrapToCheckoutFields' );
function addBootstrapToCheckoutFields($fields) {
foreach ($fields as &$fieldset) {
foreach ($fieldset as &$field) {
// if you want to add the form-group class around the label and the input
$field['class'][] = 'form-group';

// add form-control to the actual input
$field['input_class'][] = 'form-control';
}
}
return $fields;
}

@TheRaymondDev
🔶 کد تابع بهینه سازی ووکامرس و بهبود عملکرد آن بدون افزونه

function woo_noscripts_cleaner() {
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) {
$woo_styles = [
'woocommerce_frontend_styles',
'woocommerce-general',
'woocommerce-layout',
'woocommerce-smallscreen',
'woocommerce_fancybox_styles',
'woocommerce_chosen_styles',
'woocommerce_prettyPhoto_css',
'select2'
];
$woo_noscripts = [
'wc-add-payment-method',
'wc-lost-password',
'wc_price_slider',
'wc-single-product',
'wc-add-to-cart',
'wc-cart-fragments',
'wc-credit-card-form',
'wc-checkout',
'wc-add-to-cart-variation',
'wc-single-product',
'wc-cart',
'wc-chosen',
'woocommerce',
'prettyPhoto',
'prettyPhoto-init',
'jquery-blockui',
'jquery-placeholder',
'jquery-payment',
'jqueryui',
'fancybox',
'wcqi-js',
];
// Dequeue Styles
foreach ( $woo_styles as $style ) {
wp_dequeue_style( $style );
}
// Dequeue noscripts
foreach ( $woo_noscripts as $noscript ) {
wp_dequeue_noscript( $noscript );
}

}
}
add_action( 'wp_enqueue_noscripts', 'woo_noscripts_cleaner', 99 );


@TheRaymondDev
🔶 وب سایت stackoverflow که محل پرسش و پاسخ برنامه نویسان در سطح جهانی هست که متاسفانه با اینترنت ایران سازگار نیست و بدون فیلتر شکن نمی توانید صفحات stackoverflow به درستی باز کنید. 🤦‍♂️

@TheRaymondDev
🤬2
🔶 نمایش واحد پولی تومان ایران در فروشگاه ساز ایزی دیجیتال دانلود

function edd_rial_currency($formatted, $currency, $price){
if (!is_admin()) {

$price = @str_replace( edd_get_option( 'thousands_separator', ',' ) , '', $price );
$price = @$price / 10;

return $price . '';

} else {
return $price . ' ریال';
}

}

add_filter( 'edd_rial_currency_filter_after', 'edd_rial_currency', 10, 3 );
add_filter( 'edd_rial_currency_filter_before', 'edd_rial_currency', 10, 3 );


@TheRaymondDev