public function gravityFormToCart($entry)
 {
     if (CART66_PRO) {
         $formId = Cart66GravityReader::getGravityFormIdForEntry($entry['id']);
         if ($formId) {
             $productId = Cart66Product::getProductIdByGravityFormId($formId);
             if ($productId > 0) {
                 $product = new Cart66Product($productId);
                 $qty = $product->gravityCheckForEntryQuantity($entry);
                 $options = $product->gravityGetVariationPrices($entry);
                 $productUrl = Cart66Common::getCurrentPageUrl();
                 $cart = Cart66Session::get('Cart66Cart');
                 $item = $cart->addItem($productId, $qty, $options, $entry['id'], $productUrl, false, true);
                 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Cart Item Value: " . print_r($item, true));
                 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Should we use the gravity forms price? " . $product->gravity_form_pricing . ' :: Session value: ' . Cart66Session::get('userPrice_' . $product->id));
                 if ($product->gravity_form_pricing == 1) {
                     $price = Cart66GravityReader::getPrice($entry['id']) / $qty;
                     $entry_id = $item->getFirstFormEntryId();
                     $user_price_name = 'userPrice_' . $productId . '_' . $entry_id;
                     Cart66Session::set($user_price_name, $price, true);
                     // Setting the price of a Gravity Forms pricing product
                     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Using gravity forms pricing for product: Price: {$price} :: Name: " . $product->name . " :: Session variable name: {$user_price_name}");
                 }
                 $cartPage = get_page_by_path('store/cart');
                 $cartPageLink = get_permalink($cartPage->ID);
                 Cart66Session::set('Cart66LastPage', $_SERVER['HTTP_REFERER']);
                 Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Cart66 Session Dump: " . Cart66Session::dump());
                 if (!Cart66Setting::getValue('display_form_entries_before_sale')) {
                     $entry["status"] = 'unpaid';
                 }
                 RGFormsModel::update_lead($entry);
                 $cart->applyAutoPromotions();
                 do_action('cart66_after_add_to_cart', $product, $qty);
                 wp_redirect($cartPageLink);
                 exit;
             }
         }
     }
 }
示例#2
0
    echo Cart66Common::currency($item->product_price);
    ?>
</td>
        <td style="text-align: right;"><?php 
    echo Cart66Common::currency($item->product_price * $item->quantity);
    ?>
</td>
      </tr>
      <?php 
    if (!empty($item->form_entry_ids)) {
        $entries = explode(',', $item->form_entry_ids);
        $wpurl = get_bloginfo('wpurl');
        foreach ($entries as $entryId) {
            if (class_exists('RGFormsModel')) {
                if (RGFormsModel::get_lead($entryId)) {
                    $formId = Cart66GravityReader::getGravityFormIdForEntry($entryId);
                    echo "<tr><td colspan='5'>" . Cart66GravityReader::displayGravityForm($entryId) . "</td></tr>";
                    echo "<tr><td colspan='5' align='right' style='padding-bottom: 5px !important; '><a style='font-size: 10px;' href='" . $wpurl . "/wp-admin/admin.php?page=gf_entries&view=entry&id=" . $formId . "&lid=" . $entryId . "'>View Gravity Forms Entry</a></td></tr>";
                }
            } else {
                echo "<tr><td colspan='5' style='color: #955;'>" . __("This order requires Gravity Forms in order to view all of the order information", "cart66") . "</td></tr>";
            }
        }
    }
    ?>
      <?php 
}
?>
      
      <tr>
        <td colspan='4'>&nbsp;</td>