Forum Replies Created

Viewing 15 replies - 1 through 15 (of 27 total)
  • Thread Starter Josh

    (@joshguss)

    Do you have any code snippets or examples you can provide that would help point me in the right direction? Specifically an example that would demonstrate how to listen to an input field and then send that data upon checkout (assuming the user chose to be subscribed)?

    Hello-

    I seem to be having a similar issue on a site that I am working on but for us the AddToCart event is not firing for any of our Add To Cart buttons (which all are using AJAX for adding product to the cart).

    Thread Starter Josh

    (@joshguss)

    Hey @philsbury,

    Working now on my end. Thanks!

    Thread Starter Josh

    (@joshguss)

    Thanks for the info @adamkheckler. I have gone ahead and commented/voted on the provided idea so thank you for sharing that link.

    In the meantime, as a possible workaround, I am also exploring options like Integromat to connect the two platforms.

    Thanks!

    Thread Starter Josh

    (@joshguss)

    After speaking with support at ShipStation I was informed that

    WooCommerce will attempt to batch orders into a single API call, which might cause slight delays in importing if you leave them to do it on their own.

    and is therefore not always automatic/in real time. By clicking the Update All Stores button in the top right within the ShipStation dashboard, you can force ShipStation to reach out to WooCommerce to grab any outstanding orders.

    Wanted to provide this info in case others may experience something similar.

    Thread Starter Josh

    (@joshguss)

    Hey @sharmadpk03,

    I am needing to handle this in code within the theme as opposed to through another plugin. Is there any kind of developer documentation with a list of available hooks/actions/filters/functions that we could use? Was hoping to be able to do something like:

    $endpoint = UR()->query->get_current_endpoint;
    
    if ( $endpoint = 'custom-endpoint-1' ) {
      // do something for custom-endpoint-1
    } elseif ( $endpoint = 'custom-endpoint-2' ) {
      // do something for custom-endpoint-2
    } else {
      // do something else
    }
    Thread Starter Josh

    (@joshguss)

    Hello @wpclever,

    After doing some more digging, I realized that by default WooCommerce only uses Ajax to add items to the cart on shop/archive pages and not on single product pages and therefore on single product pages, the page is first reloaded before the Fly Cart is displayed (hence the delay).

    Using this tutorial I was able to implement ajax add to cart for buttons on single product pages which solved the delay issue.

    I would suggest considering this as a feature of your plugin in the future for a more seamless user experience across the store.

    Thanks!

    Thread Starter Josh

    (@joshguss)

    Hello @wpclever,

    Just wanted to check in and see if there are any updates on this.

    Thanks!

    Josh

    Thread Starter Josh

    (@joshguss)

    Hey @philsbury,

    I hear ya! I did reach out to WP Engine and unfortunately their Geolocation feature does not allow the user to override it. I spent some time yesterday reconfiguring some of the conditional work I had previously done (which was based on the PHP version) to work using the JS version and feeling pretty good about the progress thus far so I think I’m going to keep at it for now.

    Thank you again for all of your help!

    Josh

    Thread Starter Josh

    (@joshguss)

    Hey @philsbury,

    The site being developed sells alcohol online in the US but it is only able to sell/ship to specific states. We are using Age Gate to allow anyone that is 21 or older to enter the site. At the same time, we are also requesting the user’s shipping state as part of the gate (via the Age Gate Regions extension) but rather then prevent entry to users whose state is not one we are able to ship to, we allow them entry to the site (assuming they pass the age verification) and use the region data captured by the gate to customize their experience.

    The conditional content based on the state includes:

    1. Modal with info regarding inability to ship which may also include conditional content if the products are available locally
    2. A button in the header that displays the state (“Shipping to ag_user_data()->region“) which triggers a modal when clicked allowing the user to change their state.
    3. WooCommerce specific conditional content including disabling “Add to cart” buttons, disabling Cart and Checkout pages, etc.

    Numbers 1 and 2 are already built and working as they should using the PHP version of Age Gate. Number 2 is setup to update the ag_data and show_shipping_popup cookies accordingly. I do feel like both of these could also be tackled using JS with the JS version of Age Gate. Number 3 is the one I have not started in on yet but was initially planning to continue down the same path (of using the PHP version) which I think would be pretty straightforward. But after reading more about possible caching issues and needing to use the JS version to account for this, I have a feeling number 3 could get a bit more complex if needing to handle via JS.

    So that’s where I’m currently at ??

    Thanks!
    Josh

    Thread Starter Josh

    (@joshguss)

    Hey Phil,

    During development locally I have been working with the PHP version in which everything outlined above has been working great. That said, I think I am going to actually use the JS version in production due to web host caching (I’ll be working with WPEngine and noticed a couple support threads re: Age Gate, Caching and WPEngine) and am noticing the following…

    Up until now I have been using PHP to conditionally display content based on the state (region) that is entered in the gate. This works as expected in the PHP version but in switching to the JS, the PHP cookie (ag_user_data()->region) is not updated on submission since it is server side (whereas the JS ag_data cookie is) so am wondering the best way to tackle.

    Example use case…

    Region related variables

    
    $shipping_state = strtoupper(ag_user_data()->region);
    $shipping_states = get_field('shipping_states', 'option');
    $local_states = get_field('retailer_states', 'option');
    

    Conditional content

    
    if ( !in_array( $shipping_state, $shipping_states ) && in_array( $shipping_state,  $local_states) ) {
      // Not yet shipping to you but we are available locally
    } else {
      // Not yet available
    }
    

    Thanks!

    • This reply was modified 4 years, 2 months ago by Josh.
    Thread Starter Josh

    (@joshguss)

    Hey @philsbury,

    To start, thank you so much for being so helpful. To answer some of your initial questions…

    I’ve had a look, think there’s a couple of issues, unless I’m not seeing the full picture in the code, for instance where is shipping_state and shipping_states defined in the JavaScript?

    Sorry about that… I forgot to include the JS where I was declaring those variables:

    var shipping_state = '<?php echo $shipping_state; ?>';
    var shipping_states = <?php echo '["' . implode('", "', $shipping_states) . '"]' ?>;

    Regarding your assumptions, yup, both of those are correct!

    So here is where I’m at:

    1. I have added in the logic you provided in to the ag_success function we worked on in the initial thread… great idea ??
    2. I am currently using the PHP version and started by adding in the provided function to functions.php but was unable to get the modal to fire.
    3. However, by adding the code directly in footer.php a not via an action, it does work! Below is the code I used for this:
    <?php if (isset($_COOKIE['show_shipping_popup'])): ?>
      <script>
        // show the modal
        jQuery('#modal-not-shipping').modal('show');
        // Remove the cookie so it doesn't show again
        Cookies.remove('show_shipping_popup');
      </script>
    <?php endif; ?>

    Any issues you foresee by tackling it this way? If not, this seems to be working great. Thank you again for your help!

    Thread Starter Josh

    (@joshguss)

    Hey @philsbury,

    This is great and works like a charm! Thank you ??

    I saw the update the extension before seeing this response so I did not get a chance to check the console before updating but after updating to 1.0.5 the restricted region is also now working.

    Thanks so much for you help with this.

    Thread Starter Josh

    (@joshguss)

    Ok. So the provided code worked in that it allowed me to see array of data being captured. So I guess what I am having an issue is how to go about using it. For example, trying to do something like:

    
    $ag_region = ag_success($data['ag-region']);
    if ( $ag_region == 'ny' ) {
      // do something
    } else {
      // do something else
    }
    

    In terms of the extension, I can confirm I am using version 1.0.4 (see screenshot HERE). I am currently developing locally so don’t yet have a URL to share… which I realize makes this more challenging to debug :/

    Thread Starter Josh

    (@joshguss)

    Hey @philsbury,

    I am still having issues with the first issue. I tried completely deleting the plugin the re-installing the plugin, replacing the existing regions, and deleting existing regions and adding as new with -1 as the Restriction age but still no dice on my end.

    In regards to the second issue, i’m sure its just user error on my end. To test i’m just doing var_dump( ag_success($data) ); and its returning null.

Viewing 15 replies - 1 through 15 (of 27 total)