21
JS
Re: Basic shop module
  • 2010/2/17 19:08

  • JS

  • Just popping in

  • Posts: 87

  • Since: 2002/12/16


got it to work here is the completed code section for this



<table
<
tr

<{foreach 
item=cat from=$lcats}>  
    <
td
        <
center><DIV><SPAN style="FONT-SIZE: 24pt; COLOR: #bcb947; FONT-FAMILY: 'Bernard MT Condensed'; language: en-US"><{$cat.name}></SPAN></DIV></center
    </
td
 </
tr
<
tr
<
td
<
table class="item"
<
tr
<{foreach 
item=prod key=count from=$allprod}> 

 <{if 
$cat.id == $prod.catid}>

      <
td style='margin:0px;padding:5px 0px;'
          <
table><tr><td
                <
DIV><SPAN style="FONT-WEIGHT: bold; FONT-SIZE: 14pt; COLOR: #bcb947; FONT-FAMILY: Constantia; language: en-US"><{$prod.p_name}></SPAN></DIV
         
        <
br /> 
        <
DIV><SPAN style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: #bcb947; FONT-FAMILY: Constantia; language: en-US"><{$prod.p_desc_long}></SPAN></DIV
        </
td
        <
td align="right"><{if $spec.special eq 1}> 
        <
span style="text-decoration:line-through; color:#FF0000">$<{$prod.p_price}></span><br />$<{$prod.p_sp_price}> 
        <{else}> 
        <
DIV><SPAN style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; COLOR: #bcb947; FONT-FAMILY: Constantia; language: en-US">$<{$prod.p_price}></SPAN></DIV
        <{/if}> 
        </
span
        <
br /> 
        <
form method="post" action="add_to_cart.php?id=<{$prod.id}>"

           <
input type="text" name="qty" value="1" size="3" maxlength="4" title="quantity"
        <
br /> 
        <
input type="submit" value="AddToCart">  
   
</
form
        </
td
        </
tr></table
         
      </
td
      <{if 
$count is div by $colnum}> 
        </
tr
        <
tr
      <{/if}> 
<{/if}>
    <{/foreach}> 
  </
tr
</
table
</
td><tr
<{/foreach}> 
<
br /> 
</
tr
</
table>


thanks!



22
JS
Re: Help with a php function for my project
  • 2010/2/17 16:28

  • JS

  • Just popping in

  • Posts: 87

  • Since: 2002/12/16


ghia - you are correct that is what I am trying to do.

Kaotik - Sure I wouldn't mind that I have quite a bit more I would like to do with the module before I call it good and that would give me a place to release the module as well.

My intent is to keep KShop as light weight as possible but yet make it usable and easy to change if need be.



23
JS
Help with a php function for my project
  • 2010/2/16 23:32

  • JS

  • Just popping in

  • Posts: 87

  • Since: 2002/12/16


I am currently working on some different things with the old KShop module and one thing that I am working on is adding jpgraphs to the module.

I am not an expert with PHP but I can hack my way through it. one thing I am trying to do is build a function to query how much of each product is sold and put it into an array to be used with jpgraph

It would be great if someone could help guide me in the right direction.

There is a table in the datablase where KShop writes how much of each product is sold and this is where I want to pull the data from.

here is some raw output from the .sql file for that table

(`id`, `order_id`, `qty`, `p_num`, `p_name`, `p_price`) VALUES (113'A01''Apples  Option: Braeburn''12.00')


Now what I am trying to do is build a function that will query the qty (quantity) of each item ordered.

for example the array would have the following

25 apples
100 oranges
30 cookies
ect..

The values that I want to put into jpgraph is the following
total amount of each product sold
the name of each product to associate with the amount

I figured I will need to query the colums qty, p_num, p_name

here is a copy of the code I have so far. I know this does not return what I want but I was hopeing that someone could help me fix it.

function loadstats(){
    global 
$xoopsDB,$xoopsModuleConfig;
    
$stat=array();
    
    
$query $xoopsDB->query(' SELECT * FROM ' $xoopsDB->prefix('kshop_orders_products'));
    while (
$row $xoopsDB->fetchArray($query))
    {
        
$stat['qty']=$row['qty'];
        
$stat['p_num']=$row['p_num'];
        
$stat['p_name']=$row['p_name'];
        
    }

    return 
$stat;
}


Thanks!



24
JS
Re: Basic shop module
  • 2010/2/16 17:20

  • JS

  • Just popping in

  • Posts: 87

  • Since: 2002/12/16


I had a thought and I was wondering if someone could give me a sanity check. I am not at home right now so I am unable to test this.

If I insert an "IF" statment after the second foreach statment would that give me the desired result?

Example: Also I am not sure if I have the if statment formatted correctly.

<{foreach item=prod key=count from=$allprod}> 

<{if 
$prod.catid==$cat.id}> 

      <
td style='margin:0px;padding:5px 0px;'
          <
table><tr><td
                <
DIV><SPAN style="FONT-WEIGHT: bold; FONT-SIZE: 14pt; COLOR: #bcb947; FONT-FAMILY: Constantia; language: en-US"><{$prod.p_name}></SPAN></DIV>


Thanks!



25
JS
Re: Basic shop module
  • 2010/2/16 14:59

  • JS

  • Just popping in

  • Posts: 87

  • Since: 2002/12/16


Ghai thanks for the information. I believe that is exactly what I am trying to do but I will be honest I am having a difficult time translating the example over into my code.

So far I have gotten the categories to all display however for each category it is displaying all the products for all categories.

Here is a copy of my updated code

Now there is a value of $prod.catid which is the same as $cat.id also there is $prod.catname that is the same as $cat.name I am just not sure how to connect the dots correctly in the smarty.
<table>
<
tr>

<{foreach 
item=cat from=$lcats}> 
    <
td>
        <
center><DIV><SPAN style="FONT-SIZE: 24pt; COLOR: #bcb947; FONT-FAMILY: 'Bernard MT Condensed'; language: en-US"><{$cat.name}></SPAN></DIV></center>
    </
td>
 </
tr>
<
tr>
<
td>
<
table class="item">
<
tr>
<{foreach 
item=prod key=count from=$allprod}>
      <
td style='margin:0px;padding:5px 0px;'>
          <
table><tr><td>
                <
DIV><SPAN style="FONT-WEIGHT: bold; FONT-SIZE: 14pt; COLOR: #bcb947; FONT-FAMILY: Constantia; language: en-US"><{$prod.p_name}></SPAN></DIV>
        
        <
br />
        <
DIV><SPAN style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: #bcb947; FONT-FAMILY: Constantia; language: en-US"><{$prod.p_desc_long}></SPAN></DIV>
        </
td>
        <
td align="right"><{if $spec.special eq 1}>
        <
span style="text-decoration:line-through; color:#FF0000">$<{$prod.p_price}></span><br />$<{$prod.p_sp_price}>
        <{else}>
        <
DIV><SPAN style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; COLOR: #bcb947; FONT-FAMILY: Constantia; language: en-US">$<{$prod.p_price}></SPAN></DIV>
        <{/if}>
        </
span>
        <
br />
        <
form method="post" action="add_to_cart.php?id=<{$prod.id}>">

           <
input type="text" name="qty" value="1" size="3" maxlength="4" title="quantity">
        <
br />
        <
input type="submit" value="AddToCart"
  
</
form>
        </
td>
        </
tr></table>
        
      </
td>
      <{if 
$count is div by $colnum}>
        </
tr>
        <
tr>
      <{/if}>
    <{/foreach}>
  </
tr>
</
table>
</
td><tr>
<{/foreach}>
<
br />
</
tr>
</
table>



For the most part this code does exactly what I want it to do however if I could get some help getting it to only list the products for the associated category you would be a life saver.

Thanks!



26
JS
Basic foreach structure help
  • 2010/2/16 5:59

  • JS

  • Just popping in

  • Posts: 87

  • Since: 2002/12/16


Currently have one foreach call and inside that call I have another foreach call. I was wondering if anyone knew how I could customize the second foreach call to accept a var from the first foreach call.

here is an example

This is my current structure
<tr>

<{foreach 
item=cat from=$lcats}> 
    <
td>

        <{
$cat.name}><br />
    </
td>
 </
tr>
<
tr>
<
td>
<
table class="item">
<
tr>
<{foreach 
item=prod key=count from=$prods}>


Now the first foreach call lists the category name the second foreach call is suppose to list the products in the category that is in that part of that loop cycle. now I can call $cat.id to get the category id now I just need to figure out how to customize the foreach call from $prods to list the products associated with the $cat.id that the loop is on.

Any help would be great!

Thanks!



27
JS
Re: Basic shop module
  • 2010/2/16 4:54

  • JS

  • Just popping in

  • Posts: 87

  • Since: 2002/12/16


Ok i have run into an issue and I was hoping someone here is better at php then I am could help me out.

I am working on the KShop module and I am trying to get it to display the categories and products for each category on one page. I beileve that all the functions needed in the module are there and loaded however I am unable to get my code to work.

Basically this is what I am trying to get it to look like

Category1
product1 product1
product2
category2
product4 product5
product6

ect...

The code I have looks like this and I know it doesn't work and I was hoping that someone can help guide me in the right direction.
<table>
 <
tr>
<{foreach 
item=cat from=$block.shop_cats}>
 
    <
td>

        <{
$cat.name}><br />
    </
td>
 </
tr>
 <
tr>

<
table class="item">
<
tr>
<{foreach 
item=prod key=count from=$prods}>
      <
td align='center' style='margin:0px;padding:5px 0px;'>
        <
a href="<{$xoops_url}>/modules/<{$xoops_dirname}>/product_details.php?id=<{$prod.id}>" title="<{$prod.name}>">
        
        </
a><br />
        <
span style="font-size: 10px;">
        <
a href="<{$xoops_url}>/modules/<{$xoops_dirname}>/product_details.php?id=<{$prod.id}>"><{$prod.name}></a>
        <
br />
        <{if 
$spec.special eq 1}>
        <
span style="text-decoration:line-through; color:#FF0000"><{$prod.price}></span><br /><{$prod.sprice}>
        <{else}>
        <{
$prod.price}>
        <{/if}>
        </
span>
      </
td>
      <{if 
$count is div by $colnum}>
        </
tr>
        <
tr>
      <{/if}>
    <{/foreach}>
  </
tr>
</
table>
<{/foreach}>
<
br />
</
tr>
</
table>



The original module is attached to this thread if you want to look at it.



28
JS
Re: Basic shop module
  • 2010/2/14 0:46

  • JS

  • Just popping in

  • Posts: 87

  • Since: 2002/12/16


Well I have been doing some work on the Kshop and for the most part got quite a bit of it work however there are a few issues that I have dealing with right now.

First of all it does not display the categories. Now when I look at the code in the index.php it looks like it is loading the categories but since I am not great with php I am having a little issue there.

It looks like most of the code is in place to display the categories . any help in getting them to display would be great. What I am trying to do is display the Categories so they are linkable and when you click on the categories they should list the products in them.

Not sure if you can help but if so I will be happy to send you the files I am working with and you can take a look at it.

Once I can get the categories to display I can then work on formatting the apperiance of the output.

Can you help?



29
JS
Re: Basic shop module
  • 2010/2/13 20:30

  • JS

  • Just popping in

  • Posts: 87

  • Since: 2002/12/16


Actually the KShop is exactly what I am looking for. Is there a forum or something for KShop it has a few little bugs in it that I would like to try to get worked out.

Does anyone know if the original Dev is still working on it?

Thanks!



30
JS
Re: Basic shop module
  • 2010/2/13 19:00

  • JS

  • Just popping in

  • Posts: 87

  • Since: 2002/12/16


yeah that one is to heavy I have wanted KShop but I can't get it downloaded the link is dead in the modules area




TopTop
« 1 2 (3) 4 5 6 ... 9 »



Login

Who's Online

179 user(s) are online (116 user(s) are browsing Support Forums)


Members: 0


Guests: 179


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits