• Resolved gulsos

    (@gulsos)


    Need to remove shipping address using google pay when product has variation and it’s virtual

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support WebToffee Support

    (@webtoffeesupport)

    Hi @gulsos,

    Greetings from Webtoffee!


    We understand that you are looking to remove address from Google Pay. Kindly provide further clarification regarding your requirement to facilitate better understanding on our part.

    Thread Starter gulsos

    (@gulsos)

    When the woocommerce product is virtual, the plugin sees this when using google pay or apple pay and removes the shipping fields from the payment forms, but if it is a variation of the product, which is also virtual, then the form contains shipping fields, because in this case the plugin passes needs_shipping=true. So the question is how to make sure that in this case the user does not have to see and fill in the shipping fields.

    Thread Starter gulsos

    (@gulsos)

    This hook resolved problem, we checked if all variations are virtual and then if it’s true, set for product needs_shipping false

    function modify_product_needs_shipping($needs_shipping, $product) {
    if ($product->is_type('variable')) {
    $all_virtual = true;

    $available_variations = $product->get_children();

    foreach ($available_variations as $variation_id) {
    $variation = wc_get_product($variation_id);

    if (!$variation->is_virtual()) {
    $all_virtual = false;
    break;
    }
    }

    if ($all_virtual) {
    $needs_shipping = false;
    }
    }

    return $needs_shipping;
    }
    add_filter('woocommerce_product_needs_shipping', 'modify_product_needs_shipping', 10, 2);
    Plugin Support WebToffee Support

    (@webtoffeesupport)

    Hi @gulsos,

    The solution you developed appears to be accurate and should be working. We appreciate your effort in developing this. If you need any further assistance with it, let us know.

    Thread Starter gulsos

    (@gulsos)

    But this solution broke change of price in google pay form for different variations, always price of first variation. Any idea how to fix it?

    Plugin Support WebToffee Support

    (@webtoffeesupport)

    Hi @gulsos,

    The custom snippet you added may not work in all cases. Therefore, kindly remove it. If you can share your system status report from WooCommerce -> Status -> System Status -> Get system status and share it privately using this link we can explore further possibilities for a solution.

    Plugin Support WebToffee Support

    (@webtoffeesupport)

    HI @gulsos,

    This discussion thread has been inactive for some time. As a result, we will be closing it at this time. If you require further assistance, please initiate a new topic in the forum.

    Thank you for your understanding.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.