Virtuemart and using Fabrik forms - a long story

Virtue Mart

I wish to use Fabrik to add items to the Virtuemart cart instead of using the default/off the shelf addto cart button.

The reason for this is that the cost of the items is based on shippng location, and I wish to "hide" the price of items
until the user enters a postcode, this is largely academic as the user can always enet another post code.

So I have a variable running on the site that checks if a postcode has been entered...

I can display the current postcode by (all the rubbish in the code is to help me output the code in the browser so I know my logic is correct!)


Code:
<?php
global $postcode;
global $check_postcode;
echo $postcode; 
?>

I am able to run a query that takes the price from the database and adds it to the item price


Code:
Area ID =
<?php
// Make a MySQL Connection
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("dandysshop") or die(mysql_error());


 // $result = mysql_query("SELECT * FROM area
 // WHERE area_name='$postcode'") or die(mysql_error());
 // WHERE area_name LIKE '%$postcode%'") or die(mysql_error()); 



//$result = sprintf("SELECT * FROM area WHERE area_name = '%s'",
//mysql_real_escape_string($postcode));
//mysql_query($result);
//$row = mysql_fetch_array( $result );
//$area_id =  $row['area_id'];

$result = mysql_query ("SELECT * FROM area WHERE area_name LIKE '%$postcode%%%'");
$row = mysql_fetch_array( $result );
$area_id =  $row['area_id'];
echo $area_id;
?>

I can then display the price with vat on the page

Code:
<b> Cost for item directly from DB (with vat added in code) = ?
<?php
 // mysql_connect("localhost", "root", "") or die(mysql_error());
 // mysql_select_db("dandysshop") or die(mysql_error()); 

 $result = mysql_query("SELECT * FROM jos_vm_product_price
 WHERE product_id='$product_id'") or die(mysql_error());
 $row = mysql_fetch_array( $result );
 $prod_cost =  $row['product_price'] * 1.175;
 echo $prod_cost = number_format($prod_cost, 2, '.', '');
?>	
</b>
<br>
<B>
Delivery cost to  <?php echo $postcode; ?> = ?
<?php echo $cost_to_deliver; 
?>
</B>
<br>
Cost for item + Delivery Cost = 
<?php 
$cost_to_customer = $prod_cost + $cost_to_deliver;
// echo $cost_to_customer;
echo $formated_cost_to_customer = number_format($cost_to_customer, 2, '.', '');
?>
<br>

I can kill (unset) the virtuemart default price variable

Code:
<?php 
echo $product_price; 
?>
<br>********
Removed 
<?php
unset($product_price); 
echo $product_price; 
$product_price = $formated_cost_to_customer;
?>
<br>********Removing Default Price
New VM Price Variable = <?php echo $product_price; ?>
<br>********Removing Default Price
*********Show sessions*******<br>
<?php print_r($_SESSION);?><br>
<br>*********************SOME VARIABLES<br>
Category = <?php echo $category_id; ?><br>
product_id =  <?php echo $product_id; ?><br>

So with all this going on I hope to be able to pass all the details from the page via a Fabrik form ( inside the product description by way of a bot) into the
shopping cart. I can see all the arrays/variables by using the print_r($_SESSION); above.

Code:
Array
(
    [cart] => Array
        (
            [idx] => 0
        )

    [Dandys-postcode] => 
    [userstate] => Array
        (
            [product_id] => 5
        )

    [auth] => Array
        (
            [show_prices] => 1
            [user_id] => 62
            [username] => admin
            [perms] => admin
            [first_name] => 
            [last_name] => 
            [shopper_group_id] => 5
            [shopper_group_discount] => 0.00
            [show_price_including_tax] => 1
            [default_shopper_group] => 1
            [is_registered_customer] => 1
            [country] => US
            [zip] => 
        )

    [recent] => Array
        (
            [idx] => 1
            [0] => Array
                (
                    [product_id] => 5
                    [category_id] => 1
                )

        )

    [ps_vendor_id] => 1
    [minimum_pov] => 0.00
    [vendor_currency] => GBP
    [vmUseGreyBox] => 
    [vmCartDirection] => 
    [savedcart] => Array
        (
            [idx] => 0
            [0] => Array
                (
                    [quantity] => 1
                    [product_id] => 5
                    [parent_id] => 5
                    [category_id] => 1
                    [description] => 
                )

        )

    [product_sess] => Array
        (
            [5] => Array
                (
                    [tax_rate] => 0.1750
                    [vendor_id] => 1
                    [discount_info] => Array
                        (
                            [amount] => 0
                            [is_percent] => 0
                            [create_time] => 1220017780
                        )

                    [flypage] => flypage.tpl
                )

            [1] => Array
                (
                    [flypage] => flypage.tpl
                )

        )

    [VMCHECK] => OK
    [last_page] => shop.product_details
    [fabrik] => Array
        (
            [moduleErrors] => 
        )

    [last_browse_parameters] => Array
        (
            [category_id] => 1
            [manufacturer_id] => 
            [keyword] => 
            [keyword1] => 
            [keyword2] => 
            [featured] => N
            [discounted] => N
        )

)

I would like to add the product its description , (and any choices from the Fabrik form eg shipping method), and the total cost into the Viruemart cart.

I hope that someone can help thanks Steve
 
I'm afraid this is way out of scope for basic Fabrik product support.

If you want me to move this thread to the commercial Fabrik Projects forum, we can discuss helping you out on a fee paying basis.

Or re-post in Community Support, and maybe some kind soul can help you out.

-- hugh
 
Hi Hugh

Thanks for the reply, paid for support is something to think about...please could you contact me via PM with some idea of costs.

Maybe by including everything in the post I have blurred the issues.

In the meantime if you look at the the PHP/mySQL queries at the top of my post are there any pointers to get them to play with Fabrik

mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("dandysshop") or die(mysql_error());
$result = mysql_query ("SELECT * FROM area WHERE area_name LIKE '%$postcode%%%'");
$row = mysql_fetch_array( $result );
$area_id = $row['area_id'];
echo $area_id;
?>

And getting values of the arrays into fields..
 
Hi Hugh

Thanks for the reply, paid for support is something to think about...please could you contact me via PM with some idea of costs.

As I said in my last post, post something in the Fabrik Projects forum (where only you and staff members can see the posts), and we'll discuss costs there. My time is $50/hour, so what we need to nail down is exactly what you need help with, so I can give you an accurate idea of how long it might take me.

If you like I can move this whole thread so we can continue this discussion in private.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top