WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Ultra Simple Paypal Shopping Cart
Add to Cart for generated price ? WP USPP cart (2 posts)

  1. mrfunk
    Member
    Posted 10 months ago #

    Hi I run a very successfull 3d printing business. with the site hosted and built with other software and a simple site builder.. people email me a file, and I manually calculate the price.. this is getting tedious.. I have built two php scripts, which do that work for me.

    I'm creating a new website with wordpress..

    I have installed two php scripts, (STLSTATS.php & LIVEPREVIEW.php) that when a customer uploads their 3D CAD file. it generates a value(PRICE), called $pri (livepreview.php) from this value is shown on my page , in a small html file, called LivePreview.html

    I want to use one of the simple paypal buttons to use this generated price and "add to cart", but only have the option of using a fixed value in the short code.

    As the price $pri is generated in livepreview.php, do i put the short code in there? I have tried this, but can't get it to pick it up.

    I'm trying the WP ultra simple Paypal Cart
    and trying this [wp_cart:Test Product:price:15.00:end] and replacing price with $pri, and inserting this in Live-preview.php, and tried in live-preview.html

    Just get errors.

    any help would be really appreciated..

    surely this is simple.

    I'm no programmer..BTW

    http://uk-3d.co.uk/wp/

  2. mrfunk
    Member
    Posted 10 months ago #

    here is my live_preview.php which generates the price $pri

    <?php
    
        include("STLStats.php");
       // include("wp_ultra_simple_shopping_cart.php");
    
        $allowedExts = array("stl");
        $extension = strtolower( end(explode(".", $_FILES["file"]["name"])) );
    //    if (($_FILES["file"]["size"] < 200000)
    //    && in_array($extension, $allowedExts))
    		if(in_array($extension, $allowedExts))
          {
            if ($_FILES["file"]["error"] > 0)
              {
                  echo "Error: " . $_FILES["file"]["error"] . "";
              }
            else
              {
                echo "<H1>STLStats report</H1>
    
    ";
                $fname = $_FILES["file"]["tmp_name"];
                $obj = new STLStats($fname);
                echo "<u><H2>STL file Report</H2></u>";
                $unit = "cm";
                $vol = $obj->getVolume($unit);
                echo "Volume: " . $vol . " cubic " . $unit . "";
                $weight = $obj->getWeight();
                echo "Weight: " . $weight . " gm";
                $den = $obj->getDensity();
                echo "Density: " . $den . " gm/cc" . "";
                $tcount = $obj->getTrianglesCount();
                echo "Triangles Count: " . $tcount . " triangles read";
                $pri = $obj->getPrice($unit);
                echo "Price: " . $pri . "  ". "";
    
                echo "";
    
              }
          }
        else
          {
            echo "File too large or bad file extension.";
          }
    
        function __autoload($class_name) {
            include 'classes/'.$class_name . '.php';
        }
    
                ?>

    [Moderator Note: Please post code or markup between backticks or use the code button. Or better still - use a pastebin. Your posted code may now have been permanently damaged by the forum's parser.]

Reply

You must log in to post.

About this Plugin

About this Topic