Plugin Directory

Changeset 3081748


Ignore:
Timestamp:
05/06/2024 08:01:23 AM (2 years ago)
Author:
jnser
Message:

Adds product variations feature and updates button styles

Location:
stan-checkout/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • stan-checkout/trunk/README.txt

    r3079007 r3081748  
    44Requires at least: 5.0.0
    55Tested up to: 6.5.2
    6 Stable tag: 1.1.1
     6Stable tag: 1.2.0
    77License: GPLv3 or later
    88License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    9191== Mise à jour ==
    9292
     93= 1.2.0 =
     94* Ajout de la gestion des variations de produits avec le Checkout Xpress
     95
     96= 1.1.0 =
     97* Fonctionnalité de Checkout Xpress directement depuis la page produit
     98
    9399= 1.0.0 =
    94100* Première publication
  • stan-checkout/trunk/includes/classes/class-wc-stan-checkout-button.php

    r3077758 r3081748  
    3737        add_action( 'woocommerce_before_cart_totals', array( $this, 'display_stan_checkout_button_in_cart_page' ), 5 );
    3838        add_action( 'woocommerce_widget_shopping_cart_buttons', array( $this, 'display_stan_checkout_button_in_mini_cart_page' ), 10 );
    39         add_action( 'woocommerce_before_add_to_cart_button', array( $this, 'display_stan_checkout_button_in_product_page' ), 10 );
     39        add_action( 'woocommerce_after_add_to_cart_button', array( $this, 'display_stan_checkout_button_in_product_page' ), 10 );
    4040    }
    4141
  • stan-checkout/trunk/includes/classes/class-wc-stan-checkout-cart-api.php

    r3079007 r3081748  
    9191            add_filter( 'woocommerce_add_to_cart_redirect', '__return_empty_string' );
    9292            WC()->cart->empty_cart();
    93             WC()->cart->add_to_cart( $this->decode_request_payload->product_id );
     93
     94            $variation_id = null;
     95            $variations = array();
     96
     97            if ( isset( $this->decode_request_payload->variation_id ) && isset( $this->decode_request_payload->attributes ) ) {
     98                foreach( $this->decode_request_payload->attributes as $attribute )  {
     99                    $variations[ $attribute->name ] = $attribute->value;
     100                }
     101            }
     102
     103            WC()->cart->add_to_cart( $this->decode_request_payload->product_id, 1, $this->decode_request_payload->variation_id, $variations );
    94104            remove_filter( 'woocommerce_add_to_cart_redirect', '__return_empty_string' );
    95105
  • stan-checkout/trunk/public/css/wc-stan-checkout-public.css

    r3077758 r3081748  
    77}
    88#stan-checkout .stan-checkout--button {
    9     position: relative;
    109    display: flex;
    1110    flex-direction: row;
     
    1615    border-width: 0;
    1716    border-radius: 3px;
    18     height: 30px;
    19     min-height: 30px;
     17    height: 48px;
     18    min-height: 48px;
    2019    line-height: 0;
    2120    padding: 10px 15px;
    22     box-sizing: content-box;
    2321    cursor: pointer;
    2422}
  • stan-checkout/trunk/public/js/wc-stan-checkout-public.js

    r3077758 r3081748  
    2121            $( '.stan-checkout--error' ).css( 'visibility', 'hidden' );
    2222
     23            const variationsForm = $( '.variations_form.cart' );
     24
     25            const body = {
     26                product_id: $( this ).data('product'),
     27                attributes: [],
     28            }
     29
     30            if (variationsForm.length) {
     31                var variationsData = {};
     32   
     33                // Get all form elements within the variations form
     34                variationsForm.find('input, select').each(function() {
     35                    var element = $(this);
     36                   
     37                    variationsData[element.attr('name')] = element.val();
     38                });
     39
     40                for (const v in variationsData) {
     41                    if (v.includes('attribute_')) {
     42                        body.attributes.push({
     43                            name: v,
     44                            value: variationsData[v],
     45                        });
     46                    }
     47                }
     48
     49                if (typeof variationsData['variation_id'] !== 'undefined') {
     50                    body.variation_id = variationsData['variation_id'];
     51                }
     52            }
     53
    2354            fetch('/wp-json/stan/checkouts', {
    2455                method: 'POST',
    25                 body: JSON.stringify({
    26                     product_id: $( this ).data( 'product' ),
    27                 }),
     56                body: JSON.stringify(body),
    2857                credentials: 'include',
    2958            })
  • stan-checkout/trunk/wc-stan-checkout.php

    r3079007 r3081748  
    1919 * Plugin URI:        https://compte.stan-app.fr
    2020 * Description:       Vous perdez des utilisateurs lorsque vous demandez de s'inscrire, remplir les formulaires est la première raison qui mène les utilisateurs à quitter un site. Avec Stan Checkout vos utilisateurs s'inscrivent sans formulaire, sans contrainte.
    21  * Version:           1.1.1
     21 * Version:           1.2.0
    2222 * Author:            Brightweb
    2323 * Author URI:        https://stan-business.fr
Note: See TracChangeset for help on using the changeset viewer.