Forum Replies Created

Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter rabiancone

    (@rabiancone)

    They are unable to provide assistance outside of the existing functionality so I guess we are stuck.

    Is there any accounting software that your plugin works with in the manner in which I described?

    Thread Starter rabiancone

    (@rabiancone)

    Share their response about what?

    Thread Starter rabiancone

    (@rabiancone)

    Hi Sanesh,

    Thank you for replying. The plugin I use is called WooCommerce Connector by Intuit.

    Thanks,
    Ryan

    Thread Starter rabiancone

    (@rabiancone)

    Hi Angela,

    This works wonderfully.

    Thank you!

    Ryan

    Thread Starter rabiancone

    (@rabiancone)

    I figured it out. Here’s the code I used for variable products. Will require additional modification to apply to simple products as well.

    /**
     * Set pre order status when order has any pre order items
     *
     * @param string   $status      Payment status that should be set on payment complete.
     * @param int      $order_id    Order ID.
     * @param WC_Order $order       Order object.
     *
     * @return string
     */
    function vh_sto_wc_set_pre_order_status_on_payment_complete( $status, $order_id, $order ) {
        // Make a check that new status is "processing" as we don't want to do anything for virtual orders.
        // If you have to perform check for virtual orders as well then you can add or check ('processing' === $status || 'completed' === $status).
        if ( 'processing' === $status && ( 'on-hold' === $order->status || 'pending' === $order->status || 'failed' === $order->status ) ) {
            // Define has pre order false initially.
            $has_pre_order = false;
    
            // Loop through order items.
            foreach ( $order->get_items() as $item_id => $item ) {
                // Get the product object from the order item.
                $product = $item->get_product();
                // Get the product id.
                $product_id = $product->get_id();
    			$variation_id = $item->get_variation_id();
    
                // Write your logic to validate if product is a pre order product or not.
                // then store in $pre_order_checked as true/false.
                $pre_order_checked = get_post_meta( $variation_id, '_wpro_variable_is_preorder', true );
    
                if ( $pre_order_checked == 'yes' ) {
                    // assuming you perform a true condition test in if statement
                    // then set has pre order to true.
                    $has_pre_order = true;
    
                    // Break the loop as we got what we want.
                    break;
                }
            }
    
            if ( $has_pre_order == 'yes' ) {
                $status = 'preorder';
            } else {
                // Autocomplete the processing order if the pre-order is unidentified.
                $status = 'completed';
            }
        }
    
        return $status;
    }
    add_action( 'woocommerce_payment_complete_order_status', 'vh_sto_wc_set_pre_order_status_on_payment_complete', 20, 3 );
    Thread Starter rabiancone

    (@rabiancone)

    Here’s the solution for anybody who is interested:

    /**
     * Change availability text.
     *
     * @param array      $availability  Availability data array.
     * @param WC_Product $_product      WC Product object.
     *
     * @return array.
     */
    function wcs_custom_get_availability( $availability, $_product ) {
        $is_preorder = 'no';
    
        if ( $_product->is_type( 'variation' ) ) {
            $is_preorder = get_post_meta( $_product->get_id(), '_wpro_variable_is_preorder', true );
        } elseif ( $_product->is_type( 'variable' ) ) {
            $_variations     = $_product->get_available_variations();
            $_variations_ids = ! empty( $_variations ) ? wp_list_pluck( $_variations, 'variation_id' ) : array();
            if ( ! empty( $_variations_ids ) ) {
                $is_preorders = array_map(
                    function( $id ) {
                        return wc_string_to_bool( get_post_meta( $id, '_wpro_variable_is_preorder', true ) );
                    },
                    $_variations_ids
                );
                $is_preorder  = in_array( true, $is_preorders, true ) ? 'yes' : 'no';
            }
        } else {
            $is_preorder = get_post_meta( $_product->get_id(), '_simple_preorder', true );
        }
    
        if ( wc_string_to_bool( $is_preorder ) ) {
            $availability['availability'] = __( 'Available for Pre-Order', 'woocommerce' );
        }
    
        return $availability;
    }
    add_action( 'woocommerce_get_availability', 'wcs_custom_get_availability', 20, 2 );
    Thread Starter rabiancone

    (@rabiancone)

    Hi Mirko,

    The issue has not happened again since posting here. If it does I will revisit with you.

    Thanks for your help.

    Ryan

    Thread Starter rabiancone

    (@rabiancone)

    Hi Frank,

    I tried to set up a staging site to work on but too many plugins had conflicts due to licenses and other issues that I abandoned the attempt altogether and tried to figure it out myself.

    Eventually I ended up deactivating CSS optimization in Autoptimize and updated the Advanced settings in Rapidload to handle CSS optimization. This seemed to eliminate the issues with no adverse affect. Since Autoptimize was no longer handling CSS optimization I also deactivated Critical CSS.

    So far, so good. Thanks for checking in.

    Ryan

    Thread Starter rabiancone

    (@rabiancone)

    Hi Nathan,

    I’d prefer not to post anything in a public forum. Can we move this correspondence to email?

    Thread Starter rabiancone

    (@rabiancone)

    Hi Frank,

    I’m back to working directly with the RapidLoad team however nothing is bearing fruit so far as they are unable to work on my staging site and I don’t want them touching my production site.

    Nothing is clearing the cache that I’m aware of. It’s fairly random as to which pages break and how many but typically 10-20 out of 250 or so.

    One thing I failed to mention previously is the errors seem to occur on pages that use Elementor. I wonder if somehow Elementor’s CSS is conflicting.

    Thanks,
    Ryan

    Thread Starter rabiancone

    (@rabiancone)

    Absolutely!

    Thanks again

    Thread Starter rabiancone

    (@rabiancone)

    Frank,

    So far it seems to have done the trick! I’ll let you know if anything changes. Thanks so much for your help!

    Best,
    Ryan

Viewing 12 replies - 1 through 12 (of 12 total)