Uni CPO 4 Documentation
  • Introduction
  • Why Uni CPO?
  • Installation
    • Upgrade
  • How To Use
    • Plugin's Settings
    • Builder
      • Data Structure
      • General Settings
      • Non Option Variable (NOV)
      • Weight Conditional Logic
      • Dimensions Settings
      • Image Conditional Logic
      • Formula Conditional Logic
      • Dynamic labels for options/suboptions
      • Shipping Classes Conditional Logic
      • Cart Discounts
    • Basic Modules
      • Row
      • Column
      • Paragraph
      • Button
      • Image
    • Options
      • Text Input
      • Text Area
      • Select
      • Radio Inputs
      • Checkbox Inputs
      • Date Picker
      • File Upload
      • Dynamic Notice
      • Range Slider
      • Matrix
      • Extra Cart Button
      • Google Map
      • Distance by Postcode
      • Font Preview
    • Fields Conditional Logic
    • Validation Conditional Logic
    • Colorify Feature
    • Imagify Feature
    • "Free Sample" Feature
    • Arithmetic Operators
    • Manage Order Items
    • Suboptions export/import
  • For developers
    • Actions & Filters
    • JS events
    • Extending Uni CPO
  • Duplicating options and products
  • How to debug
  • Affiliation
  • Themes & Plugins Compatibility
    • Popup Maker How To
    • Boxtal
    • Pitchprint.com
    • NBDesigner
    • Toggle Tax For Woocommerce
  • FAQ
  • Refund Policy
  • Managing licenses and billing info
    • License Utilization
  • Uni CPO Add-ons
    • Custom dynamic SKU (paid)
      • Stock management based on dynamic SKU
    • "Send Inquiry" (free)
    • Hidden/disabled option (free)
Powered by GitBook
On this page

Was this helpful?

  1. Themes & Plugins Compatibility

Boxtal

It is possible to make Boxtal plugin to get weight calculated from Uni CPO and calculate its shipping rate based on this weight. However, some Boxtal functions must be modified prior that. We know that it is not good to do that, but we had no choice as Boxtal plugin does not have enough filters to make the integration in better way.

  1. Locate envoimoinscher_model.php file.

  2. Replace this function:

static function get_weight_from_order($order) {
    $total_weight = 0;
    foreach( $order->get_items( 'line_item' ) as $item ) {
        $product_id = ( $item['variation_id'] != 0 ? $item['variation_id'] : $item['product_id'] );
        $product_weight=self::get_product_weight($product_id);
        $total_weight += (int)$item['qty'] * (float)$product_weight;
    }
    return (float)$total_weight;
}

with this one:

static function get_weight_from_order($order) {
    $total_weight = 0;
    foreach( $order->get_items( 'line_item' ) as $item ) {
        $product_id = ( $item['variation_id'] != 0 ? $item['variation_id'] : $item['product_id'] );
        $product_weight=self::get_product_weight($product_id);
        $product_weight = apply_filters( 'envoimoinscher_order_line_item_weight', $product_weight, $item );
        $total_weight += (int)$item['qty'] * (float)$product_weight;
    }
    return (float)$total_weight;
}
  1. Find split_package_get_quotation function and replace this piece of the code:

foreach($best_fits[$i] as $fit_item){
      $product_id = $fit_item['variation_id'] != 0 ? $fit_item['variation_id'] : $fit_item['product_id'];
      $fit_weight += (float)self::get_product_weight($product_id) * $fit_item['quantity'];
}

with this one:

foreach($best_fits[$i] as $fit_item){
   if ( $fit_item['data']->get_weight() ) { // implementing integration with Uni CPO
      $fit_weight += $fit_item['data']->get_weight() * $fit_item['quantity'];
   } else {
      $product_id = $fit_item['variation_id'] != 0 ? $fit_item['variation_id'] : $fit_item['product_id'];
      $fit_weight += (float)self::get_product_weight($product_id) * $fit_item['quantity'];
   }
}
  1. Replace this function:

static function get_cart_weight() {
    $weight = 0;
    foreach ( WC()->cart->get_cart() as $item_id => $item ) {
        $_product = $item['data'];
        if($item['data']->needs_shipping()){
                     $product_id = ( $item['variation_id'] != 0 ? $item['variation_id'] : $item['product_id'] );
            $weight += self::get_product_weight($product_id)*$item['quantity'];
        }
    }
    return $weight;
}

with this one:

static function get_cart_weight() {
        $weight = 0;
        foreach ( WC()->cart->get_cart() as $item_id => $item ) {
            $_product = $item['data'];
            if($item['data']->needs_shipping()){
                if ( $item['data']->get_weight() ) {
                    $weight += $item['data']->get_weight() * $item['quantity'];
                } else {
                    $product_id = ( $item['variation_id'] != 0 ? $item['variation_id'] : $item['product_id'] );
                    $weight     += self::get_product_weight( $product_id ) * $item['quantity'];
                }
            }
        }
        return $weight;
}
PreviousPopup Maker How ToNextPitchprint.com

Last updated 5 years ago

Was this helpful?