פיתוח

16

כך מוסיפים כפתור “הוספה לסל” לליסטינג

השורטקוד שבסרטון (לשים בתוך סוגריים מרובעים):

				
					add_to_cart id="    " show_price="false"
				
			

ה-PHP שבסרטון:

				
					add_filter( 'woocommerce_loop_add_to_cart_link', 'quantity_inputs_for_loop_ajax_add_to_cart', 10, 2 );
function quantity_inputs_for_loop_ajax_add_to_cart( $html, $product ) {
    if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) {
        // Get the necessary classes
        $class = implode( ' ', array_filter( array(
            'button',
            'product_type_' . $product->get_type(),
            $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
            $product->supports( 'ajax_add_to_cart' ) ? 'ajax_add_to_cart' : '',
        ) ) );

        // Embedding the quantity field to Ajax add to cart button
        $html = sprintf( '%s<a rel="nofollow" href="%s" data-quantity="%s" data-product_id="%s" data-product_sku="%s" class="%s">%s</a>',
            woocommerce_quantity_input( array(), $product, false ),
            esc_url( $product->add_to_cart_url() ),
            esc_attr( isset( $quantity ) ? $quantity : 1 ),
            esc_attr( $product->get_id() ),
            esc_attr( $product->get_sku() ),
            esc_attr( isset( $class ) ? $class : 'button' ),
            esc_html( $product->add_to_cart_text() )
        );
    }
    return $html;
}

add_action( 'wp_footer' , 'archives_quantity_fields_script' );
function archives_quantity_fields_script(){
    ?>
    <script type='text/javascript'>
        jQuery(function($){
            // Update data-quantity
            $(document.body).on('click input', 'input.qty', function() {
                $(this).parent().parent().find('a.ajax_add_to_cart').attr('data-quantity', $(this).val());
                $(".added_to_cart").remove(); // Optional: Removing other previous "view cart" buttons
            }).on('click', '.add_to_cart_button', function(){
                var button = $(this);
                setTimeout(function(){
                    button.parent().find('.quantity > input.qty').val(1); // reset quantity to 1
                }, 1000); // After 1 second

            });
        });
    </script>
    <?php
}
				
			

ה-CSS שבסרטון:

				
					#btn .add_to_cart_inline {
    padding: 0px !important;
    margin: 0px;
    border: 0px !important;
}

#btn{
    height: 48px;
    text-align: center;
}

#btn .quantity input{
    width: 50px;
    border-radius: 100px;
}

#btn .quantity{
    display: inline-block;
}

#btn button{
    width: 100% ;
    height: 48px;
    margin-right: 10px;
}

#btn a:hover{
    background-color: #E12EB9;
}

#btn a.wc-forward{
    display: none;
}

				
			

UX/UI

פיתוח

בואו נעצב (רספונסיבי ו)מדהים באלמנטור – פרק שלישי

UX/UI

פיתוח

בואו נעצב מדהים באלמנטור – פרק שני

UX/UI

פיתוח

בואו נעצב מדהים באלמנטור – פרק ראשון

הצלחה

ככה תחזרו לשגרה בעסק באפקטיביות | זומליינר #21

UX/UI

3 טיפים לאפיון זורם ומדהים + יצירת Userflow | זומליינר 20#

פיתוח

אנימציית ריחוף מגניבה

פיתוח

העלמת שדות משלוח למוצרים וירטואליים

פיתוח

תוויות מרחפות בטופס אלמנטור

פיתוח

הפנייה לעמוד אחר בגלישה ממובייל

פיתוח

אנימציית סיבוב קבועה

פיתוח

שיוך תפקיד למשתמש אחרי רכישת מוצר

פיתוח

הגבלת טווחי תאריכים בטפסי אלמנטור

פיתוח

בנטו גריד באלמנטור? ועוד דינאמי?! כן כן!

UX/UI

פיתוח

3 טרנדים עיצוביים באלמנטור

הצלחה

איך לעבוד מעט ולהספיק המון – ניהול זמן למעצבים ובוני אתרים | זומליינר #9

הרשמו לעדכונים במייל

ואל תפספסו אף זום חינמי, סדנה חדשה או מדריך שווה!